I am using Visual Studio 2019, .NET Core 3.1
I create a new Project and use template Class Library (.NET Core)
I right-click on the project in the solution explorer and click Edit Project File
and add the following target:
<Target Name="Test" AfterTargets="Build">
<Message Text="This is a test" Importance="high" />
</Target>
When I publish... it hits this target a few times and in the Output pane i see "This is a test" a few times.
I would like this target to execute after the Publish instead of the build.
This works in a .NET Core Web API solution where before the Publish event i am executing an ng build on an angular project that's included in the published result.
But in a Class Library its like the Publish msbuild target never gets executed even though I am doing an actual Publish.
So...
<Target Name="Test" AfterTargets="Publish">
<Message Text="This is a test" Importance="high" />
</Target>
This message never displays in my Output pane.
This class library is going to be published to a private NuGet server and I'd like to execute a nuget push after the Publish action has completed. I can easily execute a command to push to the NuGet server once i get the msbuild target to actually run at the right time.
Am I missing something here? How can I execute a target after the Publish action finishes on a .NET Core Library solution?
EDIT: That raises another question. When i publish, i get this output:
1>------ Build started: Project: ClassLibrary1, Configuration: Release Any CPU ------
1>ClassLibrary1 -> C:\Users\11016409\Documents\source\Libraries\NET Core\ClassLibrary1\ClassLibrary1\bin\Release\netcoreapp3.1\ClassLibrary1.dll
1>This is a test
2>------ Publish started: Project: ClassLibrary1, Configuration: Release Any CPU ------
2>ClassLibrary1 -> C:\Users\11016409\Documents\source\Libraries\NET Core\ClassLibrary1\ClassLibrary1\bin\Release\netcoreapp3.1\ClassLibrary1.dll
2>This is a test
2>Successfully created package 'C:\Users\11016409\Documents\source\Libraries\NET Core\ClassLibrary1\ClassLibrary1\bin\Release\netcoreapp3.1\publish\ClassLibrary1.1.0.0.nupkg'.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
why Does it run the build phase twice?