Reputation: 62712
I know it is easy on the command line - just run dotnet publish
instead of dotnet build
, but I am building inside Visual Studio and I want a certain .Net Core project to essentially execute the dotnet publish
logic whenever VS builds it.
I am expecting for some kind of a build property. Tried to google it - did not find...
Upvotes: 4
Views: 1411
Reputation: 62712
I solved it by adding the following lines to the project file:
<Target Name="SetNoBuild">
<PropertyGroup>
<NoBuild>true</NoBuild>
</PropertyGroup>
</Target>
<Target Name="PublishAfterBuild" AfterTargets="AfterBuild" DependsOnTargets="SetNoBuild;Publish" />
<Target Name="CleanAfterBuild" AfterTargets="AfterClean">
<RemoveDir Directories="$(PublishDir)" Condition="'$(PublishDir)' != ''"/>
</Target>
I wonder if there is a simpler approach.
Upvotes: 4