使用MSBuild无法构建的项目Ctrl + Shift + B构建成功

有没有人知道我可以看看我的项目,如果我通过MSBuild控制台进行MSBuild构建之后我收到此警告:

MSB4078:MSBuild不支持项目文件’MyProject.csproj’,无法构建?

我的项目使用Target Framework .Net Core 2.0运行。 我使用的MSBuild版本是14.0.25420.1

在此处输入图像描述

这是cs.proj

在此处输入图像描述

请检查您正在运行的MSBuild版本。 我测试了15.0版本,它运行没有任何错误。

通常,请确保已为团队项目配置了构建代理,并且在代理计算机上安装Visual Studio 2017并且已安装最新的Visual Studio更新

另外,请确保为构建选择了MSbuild 15.0版。

有关详细信息,请参阅构建ASP.NET Core应用程序

引用此相关主题: 支持.NET Core .csproj文件

您正在使用新的csproj文件格式(请参阅Project sdk=...

您需要使用MSBuild 15才能构建它。 你有两个选择:

1)下载Visual Studio 2017的构建工具并安装。 然后路径将是:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin

2)如果你安装了VS,路径将是:

C:\Program Files (x86)\Microsoft Visual Studio\2017\\MSBuild\15.0\Bin

使用MSBuild 15应该修复错误。

我建议以更可靠的方式使用MSBuild。

  1. 从Visual Studio下载页面下载 Visual Studio 2017的构建工具 ,它包括最新的MSBuild 15. *( 直接链接 )。

    此处记录的命令行参数 : 使用命令行参数安装Visual Studio 2017 。

    此处列出了所有工作负载和组件: Visual Studio Build Tools 2017组件目录 。

  2. 使用PowerShell模块VSSetup查找MSBuild。 从这里下载或安装: Github:Microsoft / Visual Studio安装程序PowerShell模块

找到MS Build

 Import-Module $PSScriptRoot\VSSetup\VSSetup.psd1 $msBuildPath = (Get-VSSetupInstance | Select-VSSetupInstance -Version 15.0 -Product Microsoft.VisualStudio.Product.BuildTools).InstallationPath if ([System.IntPtr]::Size -eq 8) { $global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin\amd64' } else { $global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin' } Write-Output "Using MSBuild from $global:msbuildPath" Write-Output "MSBuild /version" $msbuild = Join-Path $global:msbuildPath msbuild & $msbuild /version