VS2010 Web 部署:如何删除绝对路径并自动化 setAcl?

发布于 2024-09-03 21:52:38 字数 578 浏览 11 评论 0原文

Visual Studio 2010 中的集成 Web 部署非常好。它可以创建一个准备使用 MSDeploy 在目标 IIS 计算机上部署的包。问题是,这个包将被重新分发到客户端,当安装 MSDeploy 时,该客户端将使用 IIS 中的“导入应用程序”自行安装它。

创建的默认包始终包含开发计算机的完整路径,即源清单文件中的“D:\Dev\XXX\obj\Debug\Package\PackageTmp”。当然,它不会阻止安装,因为它是这样设计的,但它在导入对话框中看起来很难看,并且对客户端没有任何意义。更糟糕的是,他会想知道这些路径是什么,而且看起来很混乱。

通过自定义 .csproj 文件(通过添加包创建任务使用的 MSBuild 属性),我设法向包添加其他参数。然而,我花了整个下午的大部分时间在 2600 行长的 Web.Publishing.targets 中试图了解哪些参数影响了“开发路径”行为,但徒劳无功。我还尝试在部署后使用 setAcl 自定义给定文件夹的安全性,但我只能通过使用相对路径使用 MSBuild 来做到这一点...不过,如果我解决了第一个问题,那也没关系。

我可以在创建后修改生成的存档,但我更希望一切都使用 MSBuild 自动化。有谁知道该怎么做?

The integrated Web Deployment in Visual Studio 2010 is pretty nice. It can create a package ready to be deployed using MSDeploy on a target IIS machine. Problem is, this package will be redistributed to a client that will install it himself using the "Import Application" from IIS when MSDeploy is installed.

The default package created always include the full path from the development machine, "D:\Dev\XXX\obj\Debug\Package\PackageTmp" in the source manifest file. It doesn't prevent installation of course since it was designed this way, but it looks ugly in the import dialog and has no meaning to the client. Worse he will wonder what are those paths and it looks quite confusing.

By customizing the .csproj file (by adding MSBuild properties used by the package creation task), I managed to add additional parameters to the package. However, I spent most of the afternoon in the 2600 lines long Web.Publishing.targets trying to understand what parameter influenced the "development path" behavior, in vain. I also tried to use the setAcl to customize security on a given folder after deployment, but I only managed to do this with MSBuild by using a relative path... it shouldn't matter if I resolve the first problem though.

I could modify the generated archive after its creation but I would prefer if everything was automatized using MSBuild. Does anyone know how to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

有木有妳兜一样 2024-09-10 21:52:38

显示的路径由属性_MSDeployDirPath_FullPath确定。

此属性由以下属性链设置:

  • <_MSDeployDirPath_FullPath>@(_MSDeployDirPath->'%(FullPath)')
  • <_MSDeployDirPath Include="$( _PackageTempDir)" />
  • <_PackageTempDir>$(PackageTempRootDir)\PackageTmp
  • $(IntermediateOutputPath)Package >

_MSDeployDirPath_FullPath <-- @(_MSDeployDirPath->'%(FullPath)') <-- _PackageTempDir <-- $(PackageTempRootDir)\PackageTmp

如您所见,您不能具有相对路径,因为 _MSDeployDirPath_FullPath_MSDeployDirPath 的完整路径。

但是您可以通过使用要向客户显示的路径覆盖属性 _PackageTempDir 来简化显示的路径。 (此路径将用作包生成的临时目录)

您可以覆盖该属性:

  • 在命令行中:

    msbuild.exe projectfile.csproj /t:Package /p:_PackageTempDir=C:\Package
    
  • 或者直接在项目文件中:

    <导入项目=“$(MSBuildBinPath)\Microsoft.CSharp.targets”/>
    <导入项目=“$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets”/>
    
    
    <财产组>
      <_PackageTempDir>C:\Package
    
    

The displayed path is determined by the property _MSDeployDirPath_FullPath.

This property is setted by this chain of properties:

  • <_MSDeployDirPath_FullPath>@(_MSDeployDirPath->'%(FullPath)')</_MSDeployDirPath_FullPath>
  • <_MSDeployDirPath Include="$(_PackageTempDir)" />
  • <_PackageTempDir>$(PackageTempRootDir)\PackageTmp</_PackageTempDir>
  • <PackageTempRootDir>$(IntermediateOutputPath)Package</PackageTempRootDir>

_MSDeployDirPath_FullPath <-- @(_MSDeployDirPath->'%(FullPath)') <-- _PackageTempDir <-- $(PackageTempRootDir)\PackageTmp

AS you can see, you can't have a relative path, because _MSDeployDirPath_FullPath is the fullpath of _MSDeployDirPath.

But you can simplify the displayed path by overriding the property _PackageTempDir with the path you want to be displayed to your customer. (This path will be used as a temporary directory for the package generation)

You could override the property :

  • In command line :

    msbuild.exe projectfile.csproj /t:Package /p:_PackageTempDir=C:\Package
    
  • Or directly in the project file :

    <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
    
    <!-- Must be after Microsoft.WebApplication.targets import -->
    <PropertyGroup>
      <_PackageTempDir>C:\Package</_PackageTempDir>
    </PropertyGroup>
    
折戟 2024-09-10 21:52:38

我知道这是一个老问题,接受的答案最初为我完成了这项工作,但有一个更好的方法: http://sedodream.com/2013/01/13/WebPackagingFishingTheLongPathIssue.aspx

我将代码复制到此处,以防链接失效。所有功劳都应归于作者赛义德。

Package.pubxml 文件中添加 标记:

    <PackagePath Condition=" '$(PackagePath)'=='' ">website</PackagePath>
    <EnableAddReplaceToUpdatePacakgePath Condition=" '$(EnableAddReplaceToUpdatePacakgePath)'=='' ">true</EnableAddReplaceToUpdatePacakgePath>
    <PackageDependsOn>
      $(PackageDependsOn);
      AddReplaceRuleForAppPath;
    </PackageDependsOn>

之后,但在 添加以下内容:

  <Target Name="AddReplaceRuleForAppPath" Condition=" '$(EnableAddReplaceToUpdatePacakgePath)'=='true' ">
    <PropertyGroup>
      <_PkgPathFull>$([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)))</_PkgPathFull>
    </PropertyGroup>

    <!-- escape the text into a regex -->
    <EscapeTextForRegularExpressions Text="$(_PkgPathFull)">
      <Output TaskParameter="Result" PropertyName="_PkgPathRegex" />
    </EscapeTextForRegularExpressions>

    <!-- add the replace rule to update the path -->
    <ItemGroup>
      <MsDeployReplaceRules Include="replaceFullPath">
        <Match>$(_PkgPathRegex)</Match>
        <Replace>$(PackagePath)</Replace>
      </MsDeployReplaceRules>
    </ItemGroup>
  </Target>

这是一个要点,其中包含完整的 Package.pubxml样品。

I know this is an old question and accepted answer did the job for me originally, but there is a better way: http://sedodream.com/2013/01/13/WebPackagingFixingTheLongPathIssue.aspx

I copy the code here, in case the link dies. All credit should go to Sayed - the author.

In your Package.pubxml file you add inside <Property Group> tag:

    <PackagePath Condition=" '$(PackagePath)'=='' ">website</PackagePath>
    <EnableAddReplaceToUpdatePacakgePath Condition=" '$(EnableAddReplaceToUpdatePacakgePath)'=='' ">true</EnableAddReplaceToUpdatePacakgePath>
    <PackageDependsOn>
      $(PackageDependsOn);
      AddReplaceRuleForAppPath;
    </PackageDependsOn>

And after <Property Group>, but within <Project> add this:

  <Target Name="AddReplaceRuleForAppPath" Condition=" '$(EnableAddReplaceToUpdatePacakgePath)'=='true' ">
    <PropertyGroup>
      <_PkgPathFull>$([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)))</_PkgPathFull>
    </PropertyGroup>

    <!-- escape the text into a regex -->
    <EscapeTextForRegularExpressions Text="$(_PkgPathFull)">
      <Output TaskParameter="Result" PropertyName="_PkgPathRegex" />
    </EscapeTextForRegularExpressions>

    <!-- add the replace rule to update the path -->
    <ItemGroup>
      <MsDeployReplaceRules Include="replaceFullPath">
        <Match>$(_PkgPathRegex)</Match>
        <Replace>$(PackagePath)</Replace>
      </MsDeployReplaceRules>
    </ItemGroup>
  </Target>

Here is a gist with full Package.pubxml for samples.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文