Docs: Difference from 'dotnet build'

Created on 3 Jul 2018  Â·  10Comments  Â·  Source: dotnet/docs

When should we use 'dotnet msbuild' as opposed to 'dotnet build'?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P1 doc-enhancement

All 10 comments

I ran into an issue where a build dependency loaded a Custom Assembly with a Custom Build Task in a .dll This .dll depended on .net 4.0. Using "dotnet build" the build would fail to load System 4.0.0.

Using msbuild works, so I'd assume dotnet msbuild would work the same as MsBuild.

https://github.com/dotnet/standard/issues/328
https://github.com/Azure/azure-functions-vs-build-sdk/issues/160

Seems the MSBuild version used by dotnet build is "lightweight" or "scaled back" as it can't load external assemblies..

To Clarify - Cant load external assemblies that have a dependency on .net 4.x

It is not clear whether "dotnet.exe msbuild" restores (downloads) dependencies like "dotnet.exe build" does?

@livarcocc @KathleenDollard @dsplaisted what can we add to the dotnet msbuild topic to make it more clear the distinction between dotnet build and dotnet msbuild? My understanding is that dotnet msbuild gives you the same capabilities as MSBuild, but you can also pass MSBuild parameters to dotnet build as well, right? I think the topic would benefit from having more information about the difference between the two commands.

dotnet build is basically the same as dotnet msbuild -restore -target:Build.

then what do both of them exist for?

@verbaloid Most of the time if you want to build your project you want to run dotnet build. If you have a specific target you want to run (without running the build target), you probably want to use dotnet msbuild. Basically dotnet build is the common case, but dotnet msbuild gives you more control.

thank you - now it is much more clear - can someone also update both microsoft dotnet build and msbuild pages by this guidance

one more question re. this @dsplaisted. Given that you can also pass MSBuild options to the dotnet build command, I assume you could achieve the same results with dotnet build as well, correct?

also, can you give an example of how the command would look like for this scenario you described? "if you have a specific target you want to run (without running the build target)"

dotnet build will always run the Build target.

So if you want to only run the MyTarget target, you should do dotnet msbuild -target:MyTarget. You could also do dotnet build -target:MyTarget, but that would then run both MyTarget and the Build target.

Gotcha! Thanks @dsplaisted.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tswett picture tswett  Â·  3Comments

sebagomez picture sebagomez  Â·  3Comments

gmatv picture gmatv  Â·  3Comments

ite-klass picture ite-klass  Â·  3Comments

sdmaclea picture sdmaclea  Â·  3Comments