MSBuild make it NOT copy a dependency to the output path
How in the world does this still end up copying everything but the dll? It copies the exe and runtimeconfig and deps jsons, whatever those are. I'm not going to be calling it at runtime.
3 Replies
I’m not recommending this but I wrote this for a cli tool I wanted to run automatically on build (not sure if you’re doing the same)
I am almost certain there is a better way to do it, but that basically doesn’t add the reference or do any copying but just sort of runs it in its own directory as I would manually
The inputs of the cs files is what triggers a rebuild, with the notable disadvantage that non code changes like csproj will not
Anyway, hopefully cunninghams law kicks in and someone comes in to tell us how to do it 😄
well your solution is basically equivalent to calling dotnet run
I've tried it with just dotnet run to let it build by itself
- that's kinda slow, it checking to see if it's built or not, adds half a second to every project that runs it
- they sometimes end up running it simultaneously, idk how honestly, but that breaks the build
so I'm doing
dotnet run --conriguration=$(Configuration)
(or else it won't work for release) --no-build
(can do this safely thanks to the project reference)
that just so that I don't have to hardcode the path
the annoying thing is that the cli has to run in the same mode that the project is
same configuration
if you hardcode Release for the cli project, builds break, because it still references the same configuration as itselfI think there is some subtle difference in that using the msbuild task will schedule it as part of the current compilation and won’t have the parallelism problems. That’s what I observed after switching to that from dotnet run anyway
But yes it’s probably slower than a project reference
I didn’t know about ReferenceOutputAssembly=false, maybe that’s the way