3

I want to run "dotnet msbuild" command: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-msbuild

However, I want to be able to specify the exact path to msbuild like: dotnet C:\name\msbuild.exe. (Adding it to the path is not an option)

How can I do this?

5
  • why do you need to specify the path?. just go the main project directory and run dotnet build or dotnet msbuild Commented Aug 5, 2020 at 13:56
  • I want to control the version of msbuild being used Commented Aug 5, 2020 at 13:57
  • You can just run that particular msbuild directly: C:\name\msbulid.exe. No need to involve dotnet. But really, this sounds like an XY Problem. Why are you trying to use a specific msbuild? Commented Aug 5, 2020 at 15:13
  • 1
    I am running my app in a windows server container. It does an older version of msbuild and I need the latest one, otherwise my build fails for some reason I dont get Commented Aug 5, 2020 at 15:21
  • Dotnet msbuild does not have an option to specify the msbuild version. And if you want to use different versions of msbuild, you could use Build Tool for VS2017(msbuild 15.0) or Build Tool for VS0219(msbuild 16.0) which is a lightweight build command-line tool that can be thrown away from the vs installation. See this link. And then you can call one of them based on requirements to use the specific version-----------msbuild xxx.xxproj -t:build. Commented Aug 6, 2020 at 2:32

1 Answer 1

3

However, I want to be able to specify the exact path to msbuild like: dotnet C:\name\msbuild.exe. (Adding it to the path is not an option)

Actually, dotnet msbuild does not have an option to specify which version of MSBuild to use. And MSBuild of dotnet.exe is updated with the Version of the NET Core SDK.

And as far as I know, the latest Net Core 3.+ SDK uses MSBuild 16.+ which is the latest MSBuild. So if you want to use the latest MSBuild on your windows server container, you should install the latest version of Net Core.

Note: In this way, you can only use MSBuild 16.+which supports building the old projects.

Besides, you can also install Build Tool for VS2019 or Build Tool for VS2017 to build your projects on your windows server container. Please refer to this link.

It is a lightweight build command-line tool that can be thrown away from the vs installation. When you start to install it, you need to select the related Build workload.

Build Tool for VS2017 is MSBuild 15 while Build Tool for VS2019 is MSBuild 16. You can install both of them.

Then after you finish installing it, you should launch Build Tool and then you can build them with command line msbuild xxx.xxproj -t:target.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.