"Dotnet build" command should generate an error directing you to use "dotnet msbuild" if you try to specify a target to run (/t:TargetName)
See original GitHub issueOnce you get used to using dotnet build
to build your MSBuild projects, and you learn that you can pass MSBuild command-line parameters, it’s natural to try something like this:
dotnet build MyProj.csproj /t:MyCustomTarget
That’s what I did and then I spent like an hour banging my head against the wall trying to figure out why it was trying to build the “Build” target when “MyCustomTarget” didn’t have any dependencies on it. The CLI was passing both /t:Build
and /t:MyCustomTarget
to MSBuild.
Now I know that I should use dotnet msbuild
instead of dotnet build
for this. But why the difference? I think it will be pretty common for people who want to run custom targets to not know there is a separate msbuild
command, and to run into this same issue.
I would propose that the dotnet build
command should do what the dotnet msbuild
command does today, which is to specify no specific targets. Then the default target will be built, which will be “Build” on normal projects. Then there won’t be any need for a separate dotnet msbuild
command.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:15 (13 by maintainers)
Related: CoreRT asks you to run
dotnet build /t:LinkNative
so that their additional target runs after build. Seems legit now but since a decision on howbuild
should work will require target authors to follow, it should be decided soon to avoid breaking changes that require documentation or target changes.Personally, I find it pretty odd that running
dotnet build
on my project doesn’t run the default targets that I’ve specified. Additionally, the difference betweendotnet build
anddotnet msbuild
seems artificial to me, and not very helpful. I feel like havingdotnet build
be an alias fordotnet msbuild /t:build
is only going to help people make mistakes, not avoid them. If a project specifies non-standard default targets, then why would I wantdotnet build
to run a potentially nonexistant “Build” target? Just trying to understand, maybe there’s something I’m missing.