在VSTS上构建MonoGame项目

时间:2018-04-24 19:24:42

标签: 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包但它始终不起作用。这是&lt; import&gt;标记来自 .csproject 文件:

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

非常感谢您的回答!

1 个答案:

答案 0 :(得分:1)

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

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')" />