0

我已经为 Visual Studio 2010 创建了一个项目模板,并且我在我使用的每台机器上都设置了一个环境变量。该模板引用了位于该环境变量中指向的目录中的一些资源。模板中的示例参考是:

<ItemGroup>
<Compile Include="$(MyVariable)OneDir\MyFile.txt">

关键是当我使用这个模板创建一个项目时,在 .csproj 中我得到:

<ItemGroup>
<Compile Include="..\..\..\..\Users\MyUser\AppData\......."/>

在同一个 .csproj 中,我在 .csproj 文件中替换了它:

<ItemGroup>
<Compile Include="$(MyVariable)OneDir\MyFile.txt">

那么,有什么方法可以让 csproj 在“Include”参数中写入“$(MyVariable”)?我尝试过使用与 msdn [1] 中所说的“$”字符相对应的 scape 字符 %24 : http: //msdn.microsoft.com/en-us/library/bb383819.aspx但我得到了这个.csproj:

<ItemGroup>
<Compile Include="%24..\..\..\..\Users\MyUser\AppData\......."/>
4

1 回答 1

0

尝试本文中使用解决方法。它是关于从 env 变量创建属性并在 ItemGroup 中使用它。

于 2011-10-25T11:48:46.593 回答