MSBuild-确定解决方案的_PublishedWebsites [英] MSBuild - Determine a solution's _PublishedWebsites

查看:229
本文介绍了MSBuild-确定解决方案的_PublishedWebsites的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Web开发目标文件,并希望以编程方式确定出现在"_PublishedWebsites"下方的目录的名称.

I am writing a web development targets file and would like to programmatically determine the name of the directory that appears beneath "_PublishedWebsites".

我目前必须使用此:

$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\ _ PublishedWebsites \ MyWebApplication

$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\_PublishedWebsites\ MyWebApplication

有什么想法吗?

(我不打算将其用于要发布多个网站的解决方案)

(I am not using this for solutions with more than one website to publish)

推荐答案

.NET 4.0中的新Web发布管道(WPP)具有控制输出位置的方法.

The new Web Publishing Pipeline (WPP) in .NET 4.0 has a method for controlling the output location.

首先,您需要在执行CopyWebApplication目标的过程中选择加入WPP.在命令行或MSBuild项目文件中设置以下MSBuild属性:

First, you need to opt-in to WPP during the execution of the CopyWebApplication target. Set the following MSBuild properties, either at command line or in the MSBuild project file:

<PropertyGroup>
    <UseWPP_CopyWebApplication>True</UseWPP_CopyWebApplication>
    <PipelineDependsOnBuild>False</PipelineDependsOnBuild>
</PropertyGroup>

命令行变量为:

/p:UseWPP_CopyWebApplication=True /p:PipelineDependsOnBuild=False

接下来,在与项目相同的目录中创建一个新的MSBuild目标文件,并将其命名为"ProjectName.wpp.targets",其中"ProjectName"是项目的文件名,减去扩展名.换句话说,如果您拥有"MyWebsite.csproj",则需要创建"MyWebsite.wpp.targets".我发现将目标文件也添加到项目中也有帮助.它不是必需的,但是它使编辑变得更容易.

Next, create a new MSBuild targets file in the same directory as your project and name it "ProjectName.wpp.targets" where "ProjectName" is the filename of your project, minus the extension. In other words, if you have "MyWebsite.csproj" you need to create "MyWebsite.wpp.targets". I find it helps to add the targets file to the project as well. It's not required, but it makes it easier to edit.

在新的目标文件中,您将需要覆盖WebProjectOutputDir属性.仅当将调用CopyWebApplication时才执行此操作-换句话说,当"OutDir"从"OutputPath"重定向离开时:

In the new targets file, you will need to override the WebProjectOutputDir property. Only do this when CopyWebApplication will be called - in other words, when the "OutDir" is redirected away from the "OutputPath":

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <WebProjectOutputDir Condition="'$(OutDir)' != '$(OutputPath)'">$(OutDir)Websites\MyCustomFolderName</WebProjectOutputDir>
    </PropertyGroup>
</Project>

就是这样-您应该很好.您可以通过设置OutDir属性在本地对其进行测试.不要忘了后面的反斜杠:

That's it - you should be good to go. You can test it locally by setting the OutDir property. Don't forget the trailing backslash:

msbuild MyWebsite.csproj /p:OutDir=C:\Development\WebOutputTest\

这篇关于MSBuild-确定解决方案的_PublishedWebsites的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆