【发布时间】:2017-11-06 18:53:34
【问题描述】:
我正在尝试使用 Visual Studio Code 将 Windows.Forms 应用程序移植到 .Net Standard 2.0。根据对较早问题的回答(谢谢大家),我的计划是尝试使用 Xamarin.Forms 替换 System.Windows.Forms。因此,我将 Xamarin.Forms 包添加到我的项目中。当我尝试运行 dotnet build 时,我看到以下错误:
C:\Users\<user>\.nuget\packages\xamarin.forms\2.4.0.38779\build\netstandard1.0\Xamarin.Forms.targets(51,3): error MSB4062: The "Xamarin.Forms.Build.Tasks.FixedCreateCSharpManifestResourceName" task could not be loaded from the assembly C:\Users\<user>\.nuget\packages\xamarin.forms\2.4.0.38779\build\netstandard1.0\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
我尝试添加各种其他 Microsoft.Build 包,但似乎没有任何效果。这里有前进的道路吗?这是我当前的 csproj 文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.Build" Version="15.3.409" />
<PackageReference Include="Microsoft.Build.Framework" Version="15.3.409" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.3.409" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.3.409" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="System.Configuration" Version="2.0.5" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" />
<PackageReference Include="System.ServiceModel" Version="1.0.0" />
<PackageReference Include="Xamarin.Forms" Version="2.4.0.38779" />
</ItemGroup>
</Project>
我想我可能会问与这里相同的问题:Where is the difference of dotnet build on cmd vs VS2017? 但不确定。
【问题讨论】:
-
您选择了
netcoreapp2.0。这和netstandard2.0不一样 -
是的,我实际上都试过了(netcoreapp2.0和netstandard2.0),但都报同样的错误。
标签: c# xamarin xamarin.forms msbuild .net-standard-2.0