I want to add a custom target in my .csproj file.
The custom target will be :
msbuild /t:assembleDebug
This target will just build with the Debug mode.
I have already try to modify the .csproj file but no success.
Thanks for your answers.
This target will just build with the Debug mode. I have already try to modify the .csproj file but no success.
To accomplish this, unload your project. Then at the very end of the project, just before the end-tag </Project>
, place below scripts:
<Target Name="assembleDebug" Condition=" '$(Configuration)' == 'Debug' ">
<Message Text="This custom target will only be executed when configuration is debug" Importance="high"></Message>
</Target>
With the condition '$(Configuration)' == 'Debug'
, the target will only be executed when configuration is Debug
:
When you build it with the Release mode, this custom target will not be executed:
msbuild "CustomTarget.csproj" /p:Configuration=Release /t:build;assembleDebug
Update for comment:
Can I just call : msbuild /t:assembleDebug and this target will do the same thing as msbuild /p:Configuration=Debug
/p:Configuration=Release
is used to overwrite the default configuration on Visual Studio, if you just want call : msbuild /t:assembleDebug and this target will do the same thing as msbuild /p:Configuration=Debug, you should set the default configuration to Debug, then build it with the command msbuild /t:assembleDebug
:
Then build it with that command line:
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With