0

我们有一个复杂的 Visual Studio 发布配置文件供开发人员部署文件。我希望开发人员都使用相同的发布配置文件,同时为每个未签入源代码控制的单个用户配置一些变量。这可能吗?如果是,那怎么办?

<?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>Debug</LastUsedBuildConfiguration>
      <LastUsedPlatform>Any CPU</LastUsedPlatform>
      <SiteUrlToLaunchAfterPublish />
      <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
      <ExcludeApp_Data>False</ExcludeApp_Data>
      <DeleteExistingFiles>False</DeleteExistingFiles>
      <PipelineDependsOn>
        CopyAssets;
        $(PipelineDependsOn);
      </PipelineDependsOn>
      <publishUrl>C:\inetpub\wwwroot\local.MyApp\Website</publishUrl>
    </PropertyGroup>
    <Target Name="CopyAssets">
      <Message Text="Inside of CopyAssets" Importance="high"/>
      <Exec Command="%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -File &quot;$(SolutionDir)Foundation\Scripts\Powershell\CopyAssets.ps1&quot; $(SolutionDir) $(publishUrl)"/>
    </Target>
  </Project>

这是它最简单的形式。在此示例中,我希望开发人员配置例如基于每个用户的发布 URL,如果可能的话,最好在 .user 文件中,或者从我们可以传递到此发布配置文件的某个位置获取变量或参数。

4

1 回答 1

0

我通过创建.wpp.targets文件解决了这个问题。我在我正在发布的项目中创建了一个。这使我能够定义我正在运行的 Powershell,以便为所有发布配置文件运行。

这使我能够允许开发人员定义他们自己的发布配置文件并仍然运行脚本,从而允许每个开发人员的发布 URL 值是单独的。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PipelineDependsOn>
      CopyAssets;
      $(PipelineDependsOn);
    </PipelineDependsOn>
  </PropertyGroup>

  <Target Name="CopyAssets">
    <Message Text="Inside of CopyAssets" Importance="high"/>
    <Exec Command="%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -File &quot;$(SolutionDir)Foundation\Scripts\Powershell\CopyAssets.ps1&quot; $(SolutionDir) $(publishUrl)"/>
  </Target>
</Project>

我从发布配置文件中删除了 PipelineDepndsOn 部分,并在上面定义的目标文件中进行了操作。

于 2017-08-07T17:32:27.300 回答