生成C#项目时找不到MSBuild 15,找不到“ Microsoft.Common.props”

时间:2018-08-26 17:30:34

标签: c# msbuild

我当前正在尝试构建C#项目,但是MSBuild失败并显示:

C:\Program Files\dotnet\sdk\2.1.401\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props(33,11): error MSB4226: The imported project "C:\Program Files\MSBuild\15.0\Microsoft.Common.props" was not found. Also, tried to find "15.0
\Microsoft.Common.props" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\MSBuild.d
ll.config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

我的.csproj如下:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
    <AssemblyName>MyProj</AssemblyName>
    <PackageId>MyProj</PackageId>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
  </ItemGroup>
</Project>

1 个答案:

答案 0 :(得分:0)

使用CentOS中安装的Visual代码时,我遇到了类似的问题。我尝试了一切,但问题没有解决。我所做的只是找到我的dotnet sdk path,然后尝试在文件夹中找到“ Microsoft.Common.Props” 。在我的情况下,sdK文件夹为:

/usr/share/dotnet/sdk

令人惊讶的是,我在/usr/share/dotnet/sdk/2.2.203/Current文件夹中找到了该文件,而不是/usr/share/dotnet/sdk//2.2.203/15.0/。因此,我所做的只是将文件复制并粘贴到/ usr/share/dotnet/sdk//2.2.203/15.0/位置,问题立即消失了!