Visual Studio Templates and environment variables

877 Views Asked by At

I have created a project template for Visual Studio 2010, and I have an environment variable I setted up in every machine I use. The template references some resources which are located in the directory pointed in that environment variable. A sample reference in the template is:

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

The key point is that when I create a proyect with this template, and in the .csproj I get:

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

In the same .csproj I have replace it in the .csproj file whit:

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

So, is there any way to make the csproj writes "$(MyVariable" in the "Include" parameter?. I have tried with the scape caracter %24 which correspond to the "$" character like it is saying in msdn [1]: http://msdn.microsoft.com/en-us/library/bb383819.aspx but i get this .csproj:

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

There are 1 best solutions below

0
On

Try workaround used in this post. It is about creating property from env variable and using it inside ItemGroup.