MSBuild的OutputPath属性和绝对路径

8

我正在尝试将OutputPath的值设置为绝对路径:

<OutputPath>c:\Projects\xxx\Deployment</OutputPath>

但是我遇到了这个错误:
Error   17  The expression "[System.IO.Path]::GetFullPath(D:\Projects\xxx\trunk\xxx.Web.Deployment\c:\Projects\xxx\Deployment\)" cannot be evaluated. The given path's format is not supported.     1   1   xxx.Web.Deployment

有没有一种方法可以使用绝对路径来设置OutputPath属性?我尝试过使用BaseOutputPath属性进行实验:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Deployment|AnyCPU'">
  <BaseOutputPath>C:\Projects\xxx\</BaseOutputPath>
  <OutputPath>.\Deployment</OutputPath>
  <EnableUpdateable>true</EnableUpdateable>
  <UseMerge>true</UseMerge>
  <SingleAssemblyName>xxx.Web.Deployment</SingleAssemblyName>

但是似乎被忽略了。BaseOutputPath和BaseIntermediateOutputPath用于什么?

4个回答

5
我不确定你所说的内容是否能实现,但你可以添加类似以下的内容:
<PropertyGroup>  
    <CentralisedBinariesFolderLocation>c:\wherever</CentralisedBinariesFolderLocation>
</PropertyGroup>  

<Target Name="AfterBuild">
    <Exec Command="xcopy /Y /S /F /R &quot;$(TargetPath)&quot; &quot;$(CentralisedBinariesFolderLocation)&quot;" />
</Target>

在构建之后,它将复制到相关位置。


我认为这也是正确的方法。但我有一个小问题,$(TargetPath) 没有返回任何值。是否有其他变量可以用来获取部署路径? - Frederik Vig
已经使用以下命令成功运行:<Exec Command="xcopy /Y /S /F /R $(MSBuildProjectDirectory)\Deployment $(CentralisedBinariesFolderLocation)" />。虽然不太优雅,但在我的情况下起作用了。如果有更好的方法,请告诉我! :) - Frederik Vig

3

尝试使用 OutDir 替代 OutputPath

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Deployment|AnyCPU'">
  <OutDir>C:\Projects\xxx\$(Configuration)</OutDir>
  <EnableUpdateable>true</EnableUpdateable>
  <UseMerge>true</UseMerge>
  <SingleAssemblyName>xxx.Web.Deployment</SingleAssemblyName>
</PropertyGroup>

我尝试了一下,它的输出路径是C:\Projects\xxx\$(Configuration)\_PublishedWebsites\MyApp.Website - Richard Dingwall

0

不需要按照十月份的回答中提到的所有步骤,只需将WebPublishPipelineProjectDirectory定义为与OutputPath相同的路径,这样不就可以了吗?

我在我的CI解决方案(使用CruiseControl)中尝试过,似乎可以工作。

有没有人知道从这样做中可能出现的任何副作用,而这些副作用对我来说并不明显?


0
  1. 从安装程序目录中复制 .target 和 .dll 文件
  2. 修改顶部看起来像 <UsingTask TaskName="GetProjectProperties" AssemblyFile="../../ ..lallal/VisualStudio/v10.0/Microsoft.Web.Publishing.Tasks.dll"/> 的行,并将那些 .target 和 .dll 文件复制到您正在编辑的 Microsoft.WebDeployment.targets 文件旁边的供应商文件夹中。设置属性,AssemblyFile="Microsoft.Web.Publishing.Tasks.dll"
  3. 在初始 PropertyGroup 中添加行 <EnablePackageProcessLoggingAndAssert Condition="'$(EnablePackageProcessLoggingAndAssert)' == ''">True</EnablePackageProcessLoggingAndAssert>
  4. 在实际文件/其他标签/其他构建项目文件中按您的意愿设置 OutputPath。
  5. 编辑第 290 行为 <WebPublishPipelineProjectDirectory Condition="'$(WebPublishPipelineProjectDirectory)'==''">$(OutputPath)</WebPublishPipelineProjectDirectory>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接