locked
relative path for assembly placed in windows/gac folder. RRS feed

  • Question

  • Hi,

    In my C# project and I want to reference a DLL () for both 32 bit and 64 bit in same project. So I made some changes in .CSPROJ file as shown below:

    <ItemGroup Condition="'$(Platform)' == 'x86'"> <Reference Include="XYZ, Version=7.1.0.228, Culture=neutral, PublicKeyToken=93e298a0f6b95eb1, processorArchitecture=x86">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>..\..\..\..\Windows\Microsoft.NET\assembly\GAC_32\XYZ.DLL</HintPath>
        </Reference> </ItemGroup>

    <ItemGroup Condition="'$(Platform)' == 'x64'">

    ...

    </ItemGroup>

    But in this way, if my project is not placed in C: drive then the relative path fails. And If I change it to absolute path, then also it may fail when windows drive is not C. So I tried to change the hint path to $(ProgramFiles)\..\Windows\Microsoft.NET\assembly\GAC_32\XYZ.dll. But this also did not solve the purpose because in OS like Windows XP, we are having WINNT folder and not Windows.

    Is there any way to access %windir% environment in csproj file ? or any macro which I can use to go to windows folder ?

    • Moved by Forrest Guo Wednesday, December 19, 2012 12:31 PM forums restructure (From:Developer Documentation and Help System)
    Thursday, December 13, 2012 11:32 AM

Answers

  • Hi,

    I do not have much experience with the main problem. But if you just want to get the Windows Path: Ssomething like
    $(windir)\Microsoft.Net\assembly\GAC_32\XYZ.dll
    should work because MSBUILD should be able to access Environment variables that way:
    http://msdn.microsoft.com/en-us/library/ms171459.aspx

    With kind regards,

    Konrad

    Thursday, December 13, 2012 12:27 PM

All replies

  • Hi,

    I do not have much experience with the main problem. But if you just want to get the Windows Path: Ssomething like
    $(windir)\Microsoft.Net\assembly\GAC_32\XYZ.dll
    should work because MSBUILD should be able to access Environment variables that way:
    http://msdn.microsoft.com/en-us/library/ms171459.aspx

    With kind regards,

    Konrad

    Thursday, December 13, 2012 12:27 PM
  • Thanks a lot Konrad. You solved my problem.

    $(windir) is working fine.

    Thanks again.

    Taran

    Friday, December 14, 2012 7:53 AM