我制作了一个基于 docker 容器microsoft/dotnet:1.0-sdk
。按照指南,我执行了dotnet new console
并得到一个文件dotnet.csproj
. dotnet restore
and dotnet run
worked.
现在我想添加我的真实代码,这取决于 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 包或其他东西,我want以获得最新版本。
现在当我尝试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.
I guess发生这种情况是因为在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 Core 工具进行挖矿的正确方法是什么?