VS2010 Web 部署:如何删除绝对路径并自动化 setAcl?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显示的路径由属性
_MSDeployDirPath_FullPath
确定。此属性由以下属性链设置:
<_MSDeployDirPath_FullPath>@(_MSDeployDirPath->'%(FullPath)')
<_MSDeployDirPath Include="$( _PackageTempDir)" />
<_PackageTempDir>$(PackageTempRootDir)\PackageTmp
_MSDeployDirPath_FullPath <-- @(_MSDeployDirPath->'%(FullPath)') <-- _PackageTempDir <-- $(PackageTempRootDir)\PackageTmp
如您所见,您不能具有相对路径,因为
_MSDeployDirPath_FullPath
是_MSDeployDirPath
的完整路径。但是您可以通过使用要向客户显示的路径覆盖属性
_PackageTempDir
来简化显示的路径。 (此路径将用作包生成的临时目录)您可以覆盖该属性:
在命令行中:
或者直接在项目文件中:
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 :
Or directly in the project file :
我知道这是一个老问题,接受的答案最初为我完成了这项工作,但有一个更好的方法: http://sedodream.com/2013/01/13/WebPackagingFishingTheLongPathIssue.aspx
我将代码复制到此处,以防链接失效。所有功劳都应归于作者赛义德。
在
Package.pubxml
文件中添加
标记:在
之后,但在内
添加以下内容:这是一个要点,其中包含完整的 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:And after
<Property Group>
, but within<Project>
add this:Here is a gist with full Package.pubxml for samples.