【发布时间】:2017-10-17 05:26:19
【问题描述】:
在 Visual Studio 2017 中,当使用文件系统发布方法发布 Asp.Net Core 网站时,我想在发布操作将文件复制到输出目录后触发 .bat 文件的执行。
我了解到发布操作的设置由 Visual Studio 存储在项目的 Properties/PublishProviles 目录中的 .pubxml 文件中。所以在可能的情况下文件是FolderProfile.pubxml,它目前看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<PublishFramework>net461</PublishFramework>
<ProjectGuid>f58b5ca0-8221-4c97-aa6d-7fba93a3abeb</ProjectGuid>
<publishUrl>C:\inetpub\wwwGiftOasisResponsivePublished</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
根据.pubxml 文件中的 cmets 和其他研究,我理解该文件本质上是一个 msbuild 文件,最终 msbuild 用于执行发布操作。 msbuild 文件看起来非常灵活,但有点复杂。我真的很纠结这个。
如果我的项目根目录中有一个名为finishPub.bat 的批处理文件,我如何修改上述.pubxml 文件以在将网站复制到输出文件夹后执行finishPub.bat 文件?
【问题讨论】:
-
您想仅通过 VS /“web deploy”发布执行该文件,还是在使用
dotnet publish -o C:\foo时执行该文件?第一个也使用相同的机制将dotnet publish复制到中间位置,然后复制到publishUrl中指定的位置。可能取决于bat 文件是否特定于所使用的发布配置文件。 -
我只需要通过VS发布执行文件。
标签: msbuild asp.net-core-mvc visual-studio-2017 pubxml