.NET Core Tools:导入项目时的MSB3644

时间:2017-03-09 20:35:48

标签: .net msbuild coreclr

我根据microsoft/dotnet:1.0-sdk创建了一个docker容器。按照指南,我执行了dotnet new console并获得了一个文件dotnet.csprojdotnet restoredotnet run工作。

现在我想添加我的真实代码,这取决于YamlDotNet。所以我编辑了这样的项目文件:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Yaml2Events.cs"/>
  </ItemGroup>
  <Import Project="..\..\YamlDotNet\YamlDotNet\YamlDotNet.csproj"/>
</Project>

..\..\YamlDotNet是YamlDotNet签出的路径。请不要评论使用NuGet包或其他东西,我想要拥有最新版本。

现在,当我尝试dotnet run时,我收到此错误:

/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.targets(40,3): warning MSB4011: "/usr/share/dotnet/sdk/1.0.1/Microsoft.CSharp.targets" cannot be imported again. It was already im
ported at "/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj (364,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/work/yaml-editor
/docker/src/dotnet/dotnet.csproj]
/usr/share/dotnet/sdk/1.0.1/Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v3.5" were not found. To resolve th
is, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that
 assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework
you intend. [/work/yaml-editor/docker/src/dotnet/dotnet.csproj]

The build failed. Please fix the build errors and run again.

猜测会发生这种情况,因为在YamlDotNet.csproj中,有这一行:

<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

根据错误,我猜这个版本不可用,所以我需要修补文件。我只是删除了行,这使错误更改为:

/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.targets(40,3): warning MSB4011: "/usr/share/dotnet/sdk/1.0.1/Microsoft.CSharp.targets" cannot be imported again. It was already im
ported at "/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj (363,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/work/yaml-editor
/docker/src/dotnet/dotnet.csproj]
/usr/share/dotnet/sdk/1.0.1/Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve th
is, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that
 assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework
you intend. [/work/yaml-editor/docker/src/dotnet/dotnet.csproj]

The build failed. Please fix the build errors and run again.

现在我不知所措。我不知道".NETFramework,Version=v4.0"的引用来自何处,我在YamlDotNet.csproj中找不到它。另外,我觉得我做的事情从根本上是错误的,因为我不需要修改另一个项目文件只是为了能够导入它,对吗?

那么,使用.NET核心工具导入现有项目的正确方法是什么?

0 个答案:

没有答案