Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better dll refrence paths #663

Closed
kianzarrin opened this issue Feb 7, 2020 · 7 comments · Fixed by #664
Closed

better dll refrence paths #663

kianzarrin opened this issue Feb 7, 2020 · 7 comments · Fixed by #664
Assignees
Labels
code cleanup Refactor code, remove old code, improve maintainability technical Tasks that need to be performed in order to improve quality and maintainability
Milestone

Comments

@kianzarrin
Copy link
Collaborator

kianzarrin commented Feb 7, 2020

Currently we need to copy reference paths to Dependencies/ folder in order to built this mod.
This means that we have duplicated version of each library and sometimes both get loaded by de-cpompilers slowing them down.
To add insult to injury the libraries are then copied into the bin folder creating triple version of each library.

One is good enough. It would be better to instruct .csproj to look into the application installation folder first (usingProgramFiles macro) -if that failed then we can look into Dependencies/. The copy local should also be set to false. Something like this:

    <Reference Include="Assembly-CSharp">
      <HintPath>$(ProgramFiles)\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\Assembly-CSharp.dll</HintPath>
      <HintPath>~\Library\Application Support\Steam\SteamApps\common\Cities_Skylines\Cities_Data\Managed\Assembly-CSharp.dll</HintPath>
      <HintPath>..\dependencies\Assembly-CSharp.dll</HintPath>
      <Private>False</Private>
    </Reference>

EDIT: this way it also makes the job of first time user developers easier.

@kianzarrin kianzarrin added feature A new distinct feature triage Awaiting issue categorisation labels Feb 7, 2020
@originalfoo originalfoo added this to the 11.1 milestone Feb 7, 2020
@originalfoo originalfoo added code cleanup Refactor code, remove old code, improve maintainability technical Tasks that need to be performed in order to improve quality and maintainability and removed feature A new distinct feature triage Awaiting issue categorisation labels Feb 7, 2020
@kianzarrin
Copy link
Collaborator Author

read registry: https://docs.microsoft.com/en-us/archive/blogs/msbuild/new-registry-syntax-in-msbuild-v3-5
I need Computer\HKEY_CURRENT_USER\Software\Valve\Steam : SteamPath

@originalfoo
Copy link
Member

I'd keep the following line too in case registry key not set or invalid (unlikely, but does no harm to have a fallback to program files approach):

<HintPath>$(ProgramFiles)\Steam\steamapps\common\Cities_Skylines\Cities_Data\Managed\Assembly-CSharp.dll</HintPath>

@originalfoo originalfoo modified the milestones: 11.1.0, 11.1.1 Feb 10, 2020
@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Feb 10, 2020

@aubergine10
something like this would be nice (i tested it and it works)

  <PropertyGroup>
    <SteamPath >~/Library/Application Support/Steam/</SteamPath>
    <SteamPath Condition="! Exists ('$(SteamPath)')">$(ProgramFiles)\Steam\</SteamPath> <!-- redundant? -->
    <SteamPath Condition="! Exists ('$(SteamPath)')">$(Registry:HKEY_CURRENT_USER\Software\Valve\Steam@SteamPath)</SteamPath>
    <CSDLLPath>$(SteamPath)\steamapps\common\Cities_Skylines\Cities_Data\Managed</CSDLLPath>
    <CSDLLPath Condition="!  Exists ('$(CSDLLPath)')">..\dependencies</CSDLLPath>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="ICities">
      <HintPath>$(CSDLLPath)\ICities.dll</HintPath>
      <Private>False</Private>
    </Reference>

all other interested mod owners can simply copy paste the code :)

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Feb 11, 2020

kvavks installed his Skylines in X:/SSDSteamLib/steamapps/
this is written in the file C:\Program Files (x86)\Steam\config\config.vdf which can be found using the help of registry.
in the file we have

"BaseInstallFolder_3"        "X:\SSDSteamLib"

which can be done using parsing of BaseInstallFolder and reg exp.
https://stackoverflow.com/questions/7837644/how-to-replace-string-in-file-using-msbuild
http://blogs.clariusconsulting.net/kzu/how-to-perform-regular-expression-based-replacements-on-files-with-msbuild/

I think I still can use the registry too:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 255710

EDIT:
unknown

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Feb 11, 2020

I could not access HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 255710. I get empty string.

I am guessing reading HKEY_CURRENT_USER does not require permission but HKEY_LOCAL_MACHINE does?

Another approach s to parse the file as I explained above before. Shouldn't be hard if I knew how to write XML (i don't!):
https://documentation.help/MSBuild/T_MSBuild_Community_Tasks_RegexMatch.html
https://stackoverflow.com/questions/12973019/msbuild-regexmatch-not-matching

@kianzarrin
Copy link
Collaborator Author

Also worth looking into shortcuts

I think even now we can use soft links without any actual changes :)

@kvakvs
Copy link
Collaborator

kvakvs commented Feb 12, 2020

On my screenshot you can see it was installed to F:/ (mechanical drive) and later moved to X:/ (nvme SSD drive)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Refactor code, remove old code, improve maintainability technical Tasks that need to be performed in order to improve quality and maintainability
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants