I have an asp.net project and need to run some code after each publish.
I tried to acomplish this using to ways:
- Useing the vs project file
Useing external build tool Cake (c# make)
1.) So found some topics related to this issue:
So like suggested i added following code to my project file:
<Target Name="BeforePublish">
<Message Text="BeforePublish"></Message>
<Warning Text="BeforePublish"></Warning>
</Target>
<Target Name="AfterPublish">
<Message Text="AfterPublish"></Message>
<Warning Text="AfterPublish"></Warning>
</Target>
<Target Name="MSDeployPublish" >
<Message Text="MSDeployPublish"/>
<Warning Text="MSDeployPublish"/>
</Target>
<Target Name="PipelinePreDeployCopyAllFilesToOneFolder" >
<Message Text="PipelinePreDeployCopyAllFilesToOneFolder" />
<Warning Text="PipelinePreDeployCopyAllFilesToOneFolder" />
</Target>
<Target Name="BeforeBuild">
<Message Text="BeforeBuild"></Message>
<Warning Text="BeforeBuild"></Warning>
</Target>
<Target Name="AfterBuild">
<Message Text="AfterBuild"></Message>
<Warning Text="AfterBuild"></Warning>
</Target>
But only the Before- & AfterBuild get executed. All the other targets just get ignored completly. Maybe it's because these other topics use VS 2010 and 2012. Is there a working way to do this in VS 2017?
2.) When i use following code in a task I don't get same output as when i would have compiled it with VS.
MSBuild(projectFile, new MSBuildSettings()
.WithProperty("OutDir", publishDir)
.WithProperty("DeployTarget", "WebPublish")
.WithProperty("DeployOnBuild", "true")
.WithProperty("WebPublishMethod", "FileSystem")
.WithProperty("Configuration", "Release")
);
Therefore this isn't a viable solution atm as well.
I am thankful for any help getting this to work one way or another.