msbuild - передать переменную от <Target>до <PropertyGroup> - PullRequest
0 голосов
/ 17 июня 2020

Я пытаюсь установить OutputPath в моем файле проекта как git репозиторий root.

  <Target Name="PreCompile" BeforeTargets="BeforeBuild">
    <Exec Command="git rev-parse --show-toplevel" ConsoleToMSBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="RepoRoot" />
    </Exec>
    <Message Text="repository root is: $(RepoRoot)"/>
  </Target>
  <PropertyGroup>
    <Deterministic>false</Deterministic>
    <TargetFrameworks>net461</TargetFrameworks>
    <OutputPath>$(RepoRoot)\bin\abc\$(Configuration)\</OutputPath>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>

Когда я выполняю msbuild myproj.vbproj, он генерирует следующий результат:

PreCompile:
  git rev-parse --show-toplevel
  C:/src/MyGitRepo
  repository root is: C:/src/MyGitRepo
PrepareForBuild:
  Creating directory "\bin\abc\Debug\".

Итак, $(RepoRoot) не существует внутри <PropertyGroup>. Как мне получить доступ к этой переменной в <OutputPath>?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...