c# - 在没有 Visual Studio 的情况下编译 .NET 4.6 C# 项目

标签 c# msbuild visual-studio-2015

我尝试仅使用 MSBuild 在我的构建机器上编译 .NET 4.6 C# 项目。我没有在机器上安装 Visual Studio 2015,而是安装了以下内容:

  • .NET Framework 4.6 运行时
  • .NET Framework 目标包
  • 微软构建工具 2015

我在 cmd 中运行以下命令: "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"MySolution.sln

我得到的错误是:

"error MSB4019: The imported project "C:\Microsoft.Cpp.Defaults.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk."

我已经检查过“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0”中存在“Microsoft.Cpp.Defaults.props”文件,但不在“C:\程序文件 (x86)\MSBuild\Microsoft.Cpp\v4.0\V140”。实际上,即使文件夹“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140”也不存在。

我还应该做什么/安装来编译它?

最佳答案

我遇到了同样的问题。我在运行 ms build 时通过添加以下参数来修复它。

/p:VisualStudioVersion=12.0

不是 14.0。

我引用了这个答案。

External VS2013 build error "error MSB4019: The imported project <path> was not found"

关于c# - 在没有 Visual Studio 的情况下编译 .NET 4.6 C# 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32206935/

相关文章:

C# 将字符串转换为日期时间 (AM : PM)

c# - nHibernate Distinct 和分页的问题

msbuild - (Wix) MSI 卸载非常慢。日志显示速度缓慢是在删除快捷方式时

visual-studio-2015 - 调试时导出具有 VS2015 Pro 中列出的所有属性的对象列表

c# - 动态更改 ASP.NET C# 中的项目而不需要回发?

c# - 我可以在 Blazor 中有多个 _Host.chstml 文件吗?

git - Azure云服务持续部署服务配置

msbuild - nuget 包路径中的非法字符

.net - 如何在 dotnet core 的命令 shell 中设置值

c - Visual C 强制未使用的导入,由库拉入