c# - 在 VSTS 上构建 MonoGame 项目

标签 c# build msbuild azure-devops

我在 Visual Studio Team Services 中构建我的 MonoGame 项目时遇到问题。构建解决方案时会引发错误。我搜索了很多,但没有找到任何解决方案。这是错误:

ESA\ESA.csproj(138,11): Error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\MonoGame\v3.0\MonoGame.Content.Builder.targets" was not found. Also, tried to find "MonoGame\v3.0\MonoGame.Content.Builder.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

我导入了 MonoGame nugget 包,但它总是不起作用。这是 .csproject 文件中的 标签:

<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />

非常感谢您的回答!

最佳答案

您可以在安装了 MonoGame 的机器上设置私有(private)构建代理,然后使用该构建代理构建项目。

Deploy an agent on Windows

另一方面,基于这个线程(Can't create a Continuous Integration environment due to installer issues),你可以使用NuGet包,这样你需要修改项目文件来更改导入路径<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />到实际的包路径。

您可以添加 msbuild 条件,以便在本地使用安装而不是使用 Nuget 的构建服务器。 MSBuild Conditions

例如:

<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets')" />
<Import Project="{actual package path}\MonoGame.Content.Builder.targets" Condition="!Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets')" />

关于c# - 在 VSTS 上构建 MonoGame 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50009437/

相关文章:

c# - 我将如何使用数据库创建登录表单以进行检查?

C# 遍历并设置结构中的所有字段

visual-studio-2010 - 使用 Visual Studio 2010 构建 x64 WIX 项目?

c# - MSBuild 正在用旧版本替换 Newtonsoft.Json.dll

c# - 为什么foreach循环里面的switch只执行一次

c# - 如何使用c#在tfs 2012中获取保存的查询

build - ASP.NET Core 更改构建目录

c++ - Visual Studio生成调试目标.exe文件名不匹配

android - Buck vs Gradle,Android 构建系统的优缺点

.net - 使用 MSBuild 进行 ClickOnce 部署 -> 如何传递应用程序版本/或自动增量的当前内部版本号