在Visual Studio 2017中使用文件系统发布方法发布Asp.Net核心网站时,我希望在发布操作将文件复制到输出目录后触发Properties/PublishProviles
文件的执行。
我了解到,发布操作的设置由Visual Studio存储在.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
根据finishPub.bat
文件中的评论和其他研究,我理解这个文件本质上是一个msbuild文件,最终使用msbuild来执行发布操作。 msbuild文件似乎非常灵活,但有点复杂。我真的很挣这个。
如果我的项目根目录中有一个名为.pubxml
的批处理文件,我怎么能修改上面的finishPub.bat
文件,以便在网站出现之后执行Product Version: NetBeans IDE 8.1 (Build 20151231-debian-8.1)
Java: 1.8.0_131; OpenJDK 64-Bit Server VM 25.131-b11
Runtime: OpenJDK Runtime Environment 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11
System: Linux version 4.4.0-77-generic running on amd64; UTF-8; en_US (nb)
User directory: /home/***/.netbeans/8.1
Cache directory: /home/***/.cache/netbeans/8.1
文件被复制到输出文件夹?
答案 0 :(得分:4)
您可以使用自定义目标修改发布配置文件:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
...
</PropertyGroup>
<Target Name="ExecuteBatAfterPublish" AfterTargets="AfterPublish">
<Exec Command="example.bat" WorkingDirectory="$(publishUrl)" />
</Target>
</Project>