Zdeněk Kundrát
Zdeněk Kundrát

Reputation: 120

Build MonoGame project on VSTS

I've problem with building my MonoGame project in Visual Studio Team Services. An error is thrown when the solution is built. I've searched a lot but I haven't found any solution. Here is the error:

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.

I have MonoGame nugget package imported but it always doesn't works. Here is <import> tag from .csproject file:

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

Thank you very much for your answers!

Upvotes: 3

Views: 1542

Answers (1)

starian chen-MSFT
starian chen-MSFT

Reputation: 33708

You can setup a private build agent on the machine that has MonoGame installed, then build the project with that build agent.

Deploy an agent on Windows

On the other hand, based on this thread (Can't create a Continuous Integration environment due to installer issues), you can use NuGet package, with this way you need to modify project file to change the Import path <Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" /> to the actual package path.

You can add msbuild conditions so that locally you use the installation and no the build server you use Nuget.MSBuild Conditions

For example:

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

Upvotes: 3

Related Questions