C
C#9mo ago
Falcom

C# Environment variable

Hello, I am a C# beginner and I want to modify the link of the dll to an env variable to work with several people on the project I don't know if this is good practice but I put a variable like this in my csproj file
<Reference Include="TaleWorlds.MountAndBlade">
<HintPath>$(MY_VARIABLE)\bin\myDll.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.MountAndBlade">
<HintPath>$(MY_VARIABLE)\bin\myDll.dll</HintPath>
</Reference>
But I can't find how to add them then, I tried with the windows environment variables, I searched in Visual Studio 2022 but I couldn't find how to do it. Thanks for your help
6 Replies
Jimmacle
Jimmacle9mo ago
i'm going to guess this is for modding and there isn't a proper nuget package that includes the dependencies you need? last time i needed something like this i used symlinks and didn't mess with any dynamic configuration in the project (as in, manually symlink the directory containing the binaries to a known location before opening the project)
Falcom
FalcomOP9mo ago
Yes, I don't understand very well so I have to do for example mklink C:\dll\myDll.dll secondArgument So what should I put as the second argument? And I have to do this for all dlls?
Jimmacle
Jimmacle9mo ago
you could link the whole directory instead this is the script i used in said project https://github.com/TorchAPI/Torch/blob/master/Setup%20(run%20before%20opening%20solution).bat
Falcom
FalcomOP9mo ago
In the example there is mklink /J GameBinaries "%path%" so I have to do
<Reference Include="TaleWorlds.MountAndBlade">
<HintPath>$(%path%)\bin\myDll.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.MountAndBlade">
<HintPath>$(%path%)\bin\myDll.dll</HintPath>
</Reference>
like that ? How will visual code know where to look for dll?
Jimmacle
Jimmacle9mo ago
you make the hint path point to wherever you symlinked the directory, there is no variable in it this way https://github.com/TorchAPI/Torch/blob/master/Torch.Server/Torch.Server.csproj#L106-L110
Falcom
FalcomOP9mo ago
ohhh ok Thanks a lot !!
Want results from more Discord servers?
Add your server