如何不硬编码visualstudio 2019 .csproj中的DocumentationFile路径的路径



如何动态设置DocumentationFile为引用当前用户的home drive?是否有一个$变量设置?我把我的项目签入了TFS。当我团队的另一个成员将源代码克隆到他的工作站时,.csproj中的以下节点仍然引用我硬盘上的文件夹,并且编译失败。到目前为止,我们必须手动编辑.csproj文件。谢谢。

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>C:UsersmyNamesourcereposorgNamesolutionNameprojectName.xml</DocumentationFile>
</PropertyGroup>

感谢您的回复。它引导我找到$(MSBuildProjectDirectory)变量。这里是PropertyGroup

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>$(MSBuildProjectDirectory).xml</DocumentationFile>
</PropertyGroup>

在Visual Studio中有一个常用的宏列表。

你可能想要的是$(ProjectDir)

您还可以使用存储在注册表中的环境变量。看到这个。

例子:

<FinalOutput>$(BIN_PATH)MyAssembly.dll</FinalOutput>

<Project DefaultTargets="FakeBuild">
<PropertyGroup>
<FinalOutput>$(BIN_PATH)myassembly.dll</FinalOutput>
<ToolsPath Condition=" '$(ToolsPath)' == '' ">
C:Tools
</ToolsPath>
</PropertyGroup>
<Target Name="FakeBuild">
<Message Text="Building $(FinalOutput) using the tools at $(ToolsPath)..."/>
</Target>
</Project>

最新更新