在cmd和VS2017上构建dotnet的区别在哪里? [英] Where is the difference of dotnet build on cmd vs VS2017?

查看:140
本文介绍了在cmd和VS2017上构建dotnet的区别在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

一个简单的dotnet core 2.0项目具有对Xamarin.Forms(2.3.4.270)的依赖。

A simple dotnet core 2.0 project has a dependency to Xamarin.Forms (2.3.4.270).

当我在Visual Studio中构建项目时2017(15.3),然后构建成功。在命令行上运行 dotnet build 时,它将失败,并出现以下错误:

When I build the project in Visual Studio 2017 (15.3) then the build succeeds. When running dotnet build on the command line it fails with the following error:


C:\用户\steph.nuget\软件包\xamarin.forms\2.3.4.270\构建\portable-win + net45 + wp80 + win81 + wpa81 + MonoAndroid10 + Xamarin.iOS10 + xamarinmac20\Xamarin .Forms.targets(40,3):
错误MSB4062:无法从程序集
中加载 Xamarin.Forms.Build.Tasks.FixedCreateCSharpManifestResourceName任务
C:\Users \ steph.nuget\软件包\xamarin.forms\2.3.4.270\build\portable-win + net45 + wp80 + win81 + wpa81 + MonoAndroid10 + Xamarin.iOS10 + xamarinmac20\Xamarin.Forms.Build。 Tasks.dll。
无法加载文件或程序集 Microsoft.Build.Utilities.v4.0,
Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a。
系统找不到指定的文件。确认
声明是正确的,程序集及其所有
依赖项都可用,并且任务包含实现Microsoft.Build.Framework.ITask的公共类

[C:\Users\steph\Documents\Bitbucket\time-stamp-core\TimeStamp.Core.Views\TimeStamp.Core.Views.csproj]

C:\Users\steph.nuget\packages\xamarin.forms\2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(40,3): error MSB4062: The "Xamarin.Forms.Build.Tasks.FixedCreateCSharpManifestResourceName" task could not be loaded from the assembly C:\Users\steph.nuget\packages\xamarin.forms\2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\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 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. [C:\Users\steph\Documents\Bitbucket\time-stamp-core\TimeStamp.Core.Views\TimeStamp.Core.Views.csproj]

因此,出于任何原因,都缺少了 Microsoft.Build.Utilities.v4.0 。如您在上面的屏幕截图中所见,我已经尝试添加构建实用程序,但没有成功。不管是否添加了Build Core,我都会得到相同的结果。

So for whatever reason Microsoft.Build.Utilities.v4.0 is missing. As you can see in the screenshot above I already tried to add the build utilities as well, without success. Independent on whether Build Core is added or not I'm getting the same result.

.csproj 文件:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.3.409" />
    <PackageReference Include="Xamarin.Forms" Version="2.3.4.270" />
  </ItemGroup>

</Project>

问题


  1. dotnet构建和Visual Studio 2017在构建此类项目上有何区别?我一直以为VS2017也只调用 dotnet build

  2. 如何解决此问题?

  1. Where is the difference betweend dotnet build and Visual Studio 2017 for building such kind of project? I've been under the impression that VS2017 also just calls dotnet build.
  2. How can I fix this?


推荐答案

此版本的Xamarin.Forms表单包含无法在.NET Core版本上加载的生成任务MSBuild,这就是为什么您需要使用完整版本的MSBuild(包括在VS中)的原因。

This version of the Xamarin.Forms forms contains a build task that cannot be loaded on the .NET Core version of MSBuild, which is why you need to use the full framework version of MSBuild (included in VS).

此GitHub问题

如果软件包包含MSBuild任务不是专门为支持.NET Core和.NET Framework MSBuild而编写的,这些错误很可能会发生。

If a package containing MSBuild tasks is not specifically authored to support both .NET Core and .NET Framework MSBuild, these errors are likely to occur.

这篇关于在cmd和VS2017上构建dotnet的区别在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆