[英]Add a msbuild task that runs after building a .NET Core project in Visual Studio 2017 RC
Is there something like the AfterBuild Target in msbuild with .NET Core in Visual Studio 2017 RC? 在Visual Studio 2017 RC中是否有像msbuild中的AfterBuild Target和.NET Core?
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). 我尝试将以下剪切添加到.csproj文件中,但在构建期间不会执行此操作(与VS2015相反,它可以正常工作)。
<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. 另一个有趣的发现:我认为AfterBuild目标可能已被删除 - 运行
msbuild <project.csproj> /t:AfterBuild
似乎没有调用添加的目标。 If I rename the target to "Test" an call it with msbuild <project.csproj> /t:Test
it works just fine. 如果我将目标重命名为“Test”,则使用
msbuild <project.csproj> /t:Test
调用它msbuild <project.csproj> /t:Test
它是否正常工作。
Additionally, is there any documentation on the msbuild version (and possibly the .NET Core build scripts) shipping with Visual Studio 2017 RC? 另外,是否有关于Visual Studio 2017 RC附带的msbuild版本(以及可能的.NET Core构建脚本)的任何文档?
An alternative is to use the AfterTargets attribute on the Target. 另一种方法是在Target上使用AfterTargets属性。 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”不再起作用,但这似乎是MSBuild的维护者有意识地决定的 (h / t给Livven指的是这个github问题)。 "AfterBuild" was a special name that was used by the Build target.
“AfterBuild”是Build目标使用的特殊名称。 The current version of
Microsoft.Common.CurrentVersion.targets
still has it: 当前版本的
Microsoft.Common.CurrentVersion.targets
仍然具有它:
<PropertyGroup>
<BuildDependsOn>
BeforeBuild;
CoreBuild;
AfterBuild
</BuildDependsOn>
</PropertyGroup>
<Target
Name="Build"
Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
DependsOnTargets="$(BuildDependsOn)"
Returns="$(TargetPath)" />
<!--
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.