msbuildmsbuild-taskmsbuild-target

Path.GetFullPath in MSBuild not working. What am I doing wrong?


I have several different automations in my solution.

Many of them uses [System.IO.Path]::GetFullPath to help avoid missing files and the like.

However, Recently I added another project, but for some reason the GetFullPath is not working.

What am I doing wrong?

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
  <PropertyGroup>
      <HelpPath>$([System.IO.Path]::GetFullPath('$(ProjectDir)..\..\User Guide')</HelpPath>
  </PropertyGroup>
  <Message Importance="high" Text="HelpPath=$(HelpPath)" />
</Target>

The output of the MSBuild target above

2>HelpPath=$([System.IO.Path]::GetFullPath('$(ProjectDir)..\..\User Guide')

Solution

  • You are missing a second closing brace ')' here to make it work:

        <PropertyGroup>
            <HelpPath>$([System.IO.Path]::GetFullPath('$(ProjectDir)..\..\User Guide'))</HelpPath>
        </PropertyGroup>