【问题标题】:Get parent directory of MSBuildProjectDirectory获取 MSBuildProjectDirectory 的父目录
【发布时间】:2017-08-08 19:47:42
【问题描述】:

我有项目的解决方案。此外,我在解决方案目录文件夹中有 msbuild 文件。

在 msbuild 文件中我有下一个代码:

<PropertyGroup Label="Build Directories">
   <RootPath>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)'))</RootPath>
</PropertyGroup>

<ItemGroup>
   <MSBuildProjectInfrastructure Include="$(RootPath)MyApp.Services.Infrastructure.sln">
   <AdditionalProperties>Configuration=$(Configuration);Platform=$(Platform);</AdditionalProperties>
   </MSBuildProjectInfrastructure>
 </ItemGroup>

效果不好,因为我需要进入父目录才能找到MyApp.Services.Infrastructure.sln

结构:

SolutionFolder

 -- MsBuildsFolder

 -- ProjectFile

这里是quite similar question,但不能解决我的问题

【问题讨论】:

    标签: msbuild directory parent targets


    【解决方案1】:

    要获取父文件夹,可以让MSBuild通过内置属性函数GetDirectoryNameOfFileAbove确定该文件夹中已知文件的位置:

      <PropertyGroup>
        <RootPath>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), MyApp.Services.Infrastructure.sln))</RootPath>
      </PropertyGroup> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-18
      • 2018-07-15
      • 2012-01-29
      • 2017-04-09
      • 2016-05-18
      • 1970-01-01
      相关资源
      最近更新 更多