简体   繁体   English

添加在Visual Studio 2017 RC中构建.NET Core项目后运行的msbuild任务

[英]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.

相关问题 如何在Visual Studio 2017 RC3中获取C#(。net core)项目目录路径? - How to get C# (.net core) project directory path in Visual Studio 2017 RC3? 如何使用 BuildManager 在 Visual Studio 2017 (MsBuild 15) 上构建 .Net Core 项目或解决方案 - How to use BuildManager to build .Net Core project or solution on Visual Studio 2017 (MsBuild 15) Visual Studio 2017 RC Core Console项目无法编译 - Visual Studio 2017 RC Core Console Project does not compile 项目默认XML命名空间必须是MSBuild XML命名空间错误在Visual Studio 2017.0中安装.Net Core 3后 - The default XML namespace of the project must be the MSBuild XML namespace error after Installing .Net Core 3 in Visual Studio 2017.0 Visual Studio 2017 中的空 ASP .NET Core Web 应用程序项目 - Empty ASP .NET Core Web Application project in Visual studio 2017 安装Visual Studio 2017 RC打破了dotnet核心1.0.1? - Installing Visual Studio 2017 RC breaks dotnet core 1.0.1? .NET Core,在CopyLocalLockFileAssemblies之后运行msbuild任务 - .NET Core, Running msbuild task after CopyLocalLockFileAssemblies 将新 .NET CORE 加载到 Visual Studio 2017 c# .NET CORE 项目中的问题 - Problem of loading new .NET CORE into Visual Studio 2017 c# .NET CORE project Visual Studio 2017 .net Core 2.0控制台 - Visual Studio 2017 .net core 2.0 console Visual Studio 2017 +.Net Core 2 测试不可执行 - Visual Studio 2017 + .Net Core 2 Tests not executable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM