How to compile my c# solution with msbuild from command line
How to compile my c# solution with msbuild from command line
I have a c# solution (open source, available here: https://github.com/tzachshabtay/MonoAGS) which I can compile fine from Visual Studio 2017 (Dot net framework) and from VS for Mac (Mono). I can also compile it with msbuild on Travis CI successfully on both linux and mac (https://github.com/tzachshabtay/MonoAGS/blob/master/.travis.yml).
What I can't do, is compile it on command-line from Windows 10 on my local machine. I'd like to be able to compile it both for DotNet Framework and Mono.
So I tried using MSBuild from both the mono installation and from the Build Tools for Visual Studio 2017 (note: I want to be able to install on windows even if vs2017 is not installed, though on the local machine vs2017 is installed, don't know if it matters).
Both installations are for the latest versions as of today.
Build Tools for Visual Studio 2017
This is the error I get from msbuild on mono (PATH was set to %programfiles(x86)%Monobin):
PATH
%programfiles(x86)%Monobin
Project "C:GithubMonoAGSMonoAGS.sln" (1) is building "C:GithubMonoAGSSourceTestsTests.csproj" (2) on node 1 (default targets).
Project "C:GithubMonoAGSSourceTestsTests.csproj" (2) is building "C:GithubMonoAGSSourceAGS.APIAGS.API.csproj"
(3) on node 1 (GetTargetFrameworks target(s)).
C:Program Filesdotnetsdk2.1.4SdksMicrosoft.NET.SdkSdkSdk.props(29,11): error MSB4226: The imported project "C:
Program Files (x86)MSBuild15.0Microsoft.Common.props" was not found. Also, tried to find "15.0Microsoft.Common.prop
s" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:Program Files (x86)MSBuild" . These search paths
are defined in "C:Program FilesMonolibmonomsbuild15.0binMSBuild.dll.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths. [C:GithubMonoAGSSourceAGS.
APIAGS.API.csproj]
And here's the error I get from msbuild from build tools (PATH was set to %programfiles(x86)%Microsoft Visual Studio2017BuildToolsMSBuild15.0Bin):
PATH
%programfiles(x86)%Microsoft Visual Studio2017BuildToolsMSBuild15.0Bin
Project "C:GithubMonoAGSSourceTestsTests.csproj" (2) is building "C:GithubMonoAGSSourceAGS.APIAGS.API.csproj" (3) on node 1 (GetTargetFrameworks target(s)).
C:GithubMonoAGSSourceAGS.APIAGS.API.csproj : error MSB4247: Could not load SDK Resolver. A manifest file exists, but the path to the SDK Resolver DLL file could not be found. Manifest file path 'C:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuild15.0BinSdkResolversMicrosoft.Build.NuGet
SdkResolverMicrosoft.Build.NuGetSdkResolver.xml'. SDK resolver path: C:Program Files (x86)Microsoft Visual Studio2017BuildToolsCommon7IDECommonExtens
ionsMicrosoftNuGetMicrosoft.Build.NuGetSdkResolver.dll
As for the mono error, the MSBuild15.0 folder exists but Microsoft.Common.props is not there (and I couldn't find it anywhere else on that machine).
MSBuild15.0
Microsoft.Common.props
As for the build tools error, the CommonExtensions folder exists but there is no Microsoft folder in it.
CommonExtensions
Microsoft
The command I'm trying is:msbuild /p:Configuration=DEBUG /p:Platform="Any CPU" MonoAGS.sln
msbuild /p:Configuration=DEBUG /p:Platform="Any CPU" MonoAGS.sln
Why doesn't it work? What am I missing?
Thanks.
1 Answer
1
How to compile my c# solution with msbuild from command line
For the build tools error, you should install the component NuGet package manager by Visual Studio Installer:

When we use the Visual Studio build tool to build our project, we also need to install some of the necessary components for our project.
For the mono error, since I do not have mono ENV, I could not specify the directly reason for that error, if possible, you can try to install Mono framework. If it not helps, you can open a new thread with mono and msbuild tags.
Update:
How do I install it with command-line, btw (for setting up a script)?
Yes, you can use vs_buildtools.exe to install that component ID Microsoft.VisualStudio.Component.NuGet:
vs_buildtools.exe
vs_buildtools.exe --add Microsoft.VisualStudio.Component.NuGet --quiet
Note: You should rename vs_buildtools__2048890300.15156xxxx.exe to vs_buildtools.exe, then use vs_buildtools.exe to install it.
vs_buildtools__2048890300.15156xxxx.exe
vs_buildtools.exe
Check the Visual Studio Build Tools 2017 component directory and Use command-line parameters to install Visual Studio 2017 for some more details.
Hope this helps.
Thanks, it works. Note that I also had to install .net core workflow (even though I'm using framework, see here: github.com/Microsoft/msbuild/issues/2532). As for command line instructions, found a link here: docs.microsoft.com/en-us/visualstudio/install/… (ah, nvm, saw you posted an update, thanks!)
– tzachs
Sep 18 '18 at 2:14
@tzachs, Yes, we could install it by the command line
vs_buildtools.exe --add Microsoft.VisualStudio.Component.NuGet --quiet.– Leo Liu-MSFT
Sep 18 '18 at 2:15
vs_buildtools.exe --add Microsoft.VisualStudio.Component.NuGet --quiet
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy
Thanks, I'll give it a try tonight and update (if you're part of the product, btw, a better error message would be appreciated). How do I install it with command-line, btw (for setting up a script)? As for mono, I do have it installed (and your links are for Mac, where the problem is on Windows).
– tzachs
Sep 17 '18 at 16:07