Is there something like the AfterBuild Target in msbuild with .NET Core in Visual Studio 2017 RC?
I tried to add the following snipped to the .csproj file, but it is not excuted during a build (Contrary to VS2015 where it does work).
<Target Name="AfterBuild"> <Message Importance="High" Text="This is a test" /> </Target>
Another interesting discovery: As I thought that the AfterBuild target might have been removed - running msbuild <project.csproj> /t:AfterBuild
doesn't seem to call the added target. If I rename the target to "Test" an call it with msbuild <project.csproj> /t:Test
it works just fine.
Additionally, is there any documentation on the msbuild version (and possibly the .NET Core build scripts) shipping with Visual Studio 2017 RC?
With Visual Studio 2019 and later, it's installed under the Visual Studio installation folder. For a typical default installation on Windows 10, MSBuild.exe is under the installation folder in MSBuild\Current\Bin. In the installer, make sure MSBuild tools for the workloads you use are selected, and choose Install.
An MSBuild custom task is a class that implements the ITask interface.
The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software. Visual Studio uses MSBuild, but MSBuild doesn't depend on Visual Studio.
You can also get the MSBuild executable as a Nuget package https://www.nuget.org/packages/Microsoft.Build.Runtime/.
An alternative is to use the AfterTargets attribute on the Target. Something like:
<Target Name="TestTarget" AfterTargets="Build"> <Message Importance="High" Text="This is a test" /> </Target>
I'm not sure why "AfterBuild" wouldn't work any more, but this appears to be a conscious decision by the maintainers of MSBuild (h/t to Livven on pointing me to this github issue). "AfterBuild" was a special name that was used by the Build target. The current version of Microsoft.Common.CurrentVersion.targets
still has it:
<PropertyGroup> <BuildDependsOn> BeforeBuild; CoreBuild; AfterBuild </BuildDependsOn> </PropertyGroup> <Target Name="Build" Condition=" '$(_InvalidConfigurationWarning)' != 'true' " DependsOnTargets="$(BuildDependsOn)" Returns="$(TargetPath)" /> <!--
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