Reputation: 191129
Let's say I have a directory A, and has a project file x.csproj and sln in that directory. I also have resource file x.resources in it.
How can I set the resource file without the absolute path C:\A\x.resources
, but relative path .\x.resources
? I tried with x.resources
but it doesn't work.
Upvotes: 4
Views: 9579
Reputation: 502
NOTE: Visual Studio sometimes puts the <PropertyGroup> <Win32Resource>
too early in the .csproj, so you would need to manually edit the XML and move the <PropertyGroup>
after the <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
element so the reference will be relative to the .csproj file.
Upvotes: 0
Reputation: 1691
I realize that the asker was using .NET, but just as an FYI, for C++ projects you have to edit your VCXPROJ file, and the resources are stored in a slightly different format near the bottom of the file.
Original:
<ItemGroup>
<Image Include="C:\projects\dragdroptree\DragDropView\res\bmp00001.bmp" />
<Image Include="C:\projects\dragdroptree\DragDropView\res\toolbar1.bmp" />
</ItemGroup>
Modified:
<ItemGroup>
<Image Include="res\toolbar.bmp" />
<Image Include="res\bmp00001.bmp" />
</ItemGroup>
Just to clarify, the paths you put in there are relative to the directory that the VCXPROJ file is in.
Upvotes: 1
Reputation: 196
Just ran into the same problem. My co-worker didn't even try to fix it in the UI but just hacked the CSPROJ file in a text editor:
CSPROJ Path: C:\foo\bar\SolutionNm\ProjectNm\ProjectNm.csproj
Res Path: C:\foo\bar\Icons.res
Original:
<PropertyGroup>
<Win32Resource>C:\foo\bar\Icons.res</Win32Resource>
</PropertyGroup>
Modified:
<PropertyGroup>
<Win32Resource>..\..\Icons.res</Win32Resource>
</PropertyGroup>
As long as you don't try to modify the value in the UI again, it won't complain
Cheers, Aaron
Upvotes: 6