Snoothy / UCR

Universal Control Remapper [Alpha]
MIT License
834 stars 84 forks source link

Build with Visual Studio 2022 #301

Open garfieldbanks opened 1 year ago

garfieldbanks commented 1 year ago

First thing I had to do was add the nuget package sources. In visual studio 2022 go to: Tools > NuGet Package Manager > Package Manager Settings > Package Sources. Then add this source: "https://api.nuget.org/v3/index.json"

I tried running "./build.ps1 InitProject" but it gives this error:

click to see error... > @ D:\Projects\UCR > Error output: > Input file does not exist: D:\Projects\UCR\submodules\IOWrapper\IOWrapper.sln. > > at Nuke.Common.Tooling.ProcessExtensions.AssertZeroExitCode(IProcess process) > at Nuke.Common.Tools.NuGet.NuGetTasks.NuGetRestore(NuGetRestoreSettings toolSettings) > at Build.b__31_1() in D:\Projects\UCR\build\Build.cs:line 76 > at Nuke.Common.Utilities.Collections.EnumerableExtensions.ForEach[T](IEnumerable`1 enumerable, Action`1 action) > at Nuke.Common.Execution.BuildExecutor.Execute(NukeBuild build, ExecutableTarget target, IReadOnlyCollection`1 previouslyExecutedTargets, Boolean failureMode) > at Nuke.Common.Utilities.Collections.EnumerableExtensions.ForEach[T](IEnumerable`1 enumerable, Action`1 action) > at Nuke.Common.Execution.BuildExecutor.Execute(NukeBuild build, IReadOnlyCollection`1 skippedTargets) > at Nuke.Common.Execution.BuildManager.Execute[T](Expression`1 defaultTargetExpression) > > Repeating warnings and errors: > Input file does not exist: D:\Projects\UCR\submodules\IOWrapper\IOWrapper.sln. > Process 'NuGet.exe' exited with code 1.

Trying to build with Visual Studio itself gives a similar IOWrapper does not exist error.

garfieldbanks commented 1 year ago

OK I had to run "git submodule update --init --recursive" to get it.

garfieldbanks commented 1 year ago

Now I'm getting errors trying to build IOWrapper:

click to see the error... > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3274: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\DataObjects\bin\Debug\IOWrapper.DTOs.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Core_Interception\bin\Debug\Core_Interception.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.DTOs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\SharpDX_DirectInput\bin\Debug\SharpDX_DirectInput.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.DTOs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3274: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Core_Interception\bin\Debug\Core_Interception.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3274: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\SharpDX_DirectInput\bin\Debug\SharpDX_DirectInput.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Core_Interception\bin\Debug\Core_Interception.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.DeviceLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\SharpDX_DirectInput\bin\Debug\SharpDX_DirectInput.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.DeviceLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Core_Interception\bin\Debug\Core_Interception.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.PollingDeviceHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\SharpDX_DirectInput\bin\Debug\SharpDX_DirectInput.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.PollingDeviceHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Core_Interception\bin\Debug\Core_Interception.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.SubscriptionHandlers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\SharpDX_DirectInput\bin\Debug\SharpDX_DirectInput.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.SubscriptionHandlers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Core_Interception\bin\Debug\Core_Interception.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.HidDeviceHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\SharpDX_DirectInput\bin\Debug\SharpDX_DirectInput.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.ProviderLogger, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\SharpDX_DirectInput\bin\Debug\SharpDX_DirectInput.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.PovHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Core_Interception\bin\Debug\Core_Interception.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.EmptyEventDictionary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3275: The primary reference "D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\SharpDX_DirectInput\bin\Debug\SharpDX_DirectInput.dll" could not be resolved because it has an indirect dependency on the assembly "IOWrapper.Libraries.EmptyEventDictionary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" which was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.2". > 1>D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Provider Unit Tests\InterceptionMouseButtonTests.cs(1,7,1,24): error CS0246: The type or namespace name 'Core_Interception' could not be found (are you missing a using directive or an assembly reference?) > 1>D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Provider Unit Tests\InterceptionMouseButtonTests.cs(2,7,2,24): error CS0246: The type or namespace name 'Core_Interception' could not be found (are you missing a using directive or an assembly reference?) > 1>D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Provider Unit Tests\UnsignedToSigned.cs(8,7,8,26): error CS0246: The type or namespace name 'SharpDX_DirectInput' could not be found (are you missing a using directive or an assembly reference?) > 1>D:\Projects\UCR\submodules\IOWrapper\Source\Core Providers\Provider Unit Tests\UnsignedToSigned.cs(15,17,15,32): error CS0246: The type or namespace name 'DiAxisProcessor' could not be found (are you missing a using directive or an assembly reference?)
garfieldbanks commented 1 year ago

I was able to build IOWrapper by making sure everything was retargeted to 4.8.0. Then I had to copy the contents of "submodules\IOWrapper\Artifacts" to a new folder "dependencies" in the main folder. Then I had to retarget everything in UCR to 4.8.0 and I was able to get a build to succeed:

click to see the screenshot... ![image](https://user-images.githubusercontent.com/12904270/223565962-f42a01e0-81b9-42d9-89ac-6da0ad3f42ba.png)
garfieldbanks commented 1 year ago

The reason I started down this path is because I wanted the minimize to tray ability so I had to find the branch where this was done: https://github.com/Snoothy/UCR/tree/feature/plugingui-naming

The first build I made of it crashed because it was trying to init the jumplist but had a null exception error. Maybe it needs an initial config file or something idk. I made a new build with that line commented out.

garfieldbanks commented 1 year ago

OK that last build had a couple more exceptions. This time I didn't comment out that jumplist line. Instead I put a try catch around it and just printed the exception to the log file. I made two other similar try catches for other lines that were throwing exceptions. As far as I can tell it works now. I can activate my profiles and minimize to the tray. The only thing is it doesn't fully close sometimes (this happens in the original as well I think) so I start it with a bat/cmd file to kill off the previous UCR.exe before opening the new one. I included the cmd file in the zip. Just create your shortcut to that and hopefully it all works now. If not I'll post a new version here.

garfieldbanks commented 1 year ago

Had to comment out the jumplist thing and also catch some exceptions.

garfieldbanks commented 1 year ago

Found another exception to catch: UCR-tray.zip

Retroomer commented 7 months ago

Found another exception to catch: UCR-tray.zip

Would you mind forking the repo, applying your fixes & sharing it? I'd love to write some plugins as well but I just can't get the base project to build. I've been having some issues retargeting everything: Perhaps I'm forgetting something, or it's just not working. No idea...

garfieldbanks commented 7 months ago

I didn't really make that many changes but I could try to help you debug your build problems. First let's start over from scratch to make it easier for me to help you. Let me know the exact error message you get after following these instructions:

  1. Download and install .NET 4.5.2 from: https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net452-developer-pack-offline-installer and .NET 4.6.1 from: https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net461-developer-pack-offline-installer
  2. Create a new empty folder: e.g. c:/Projects/UCR
  3. Open a command prompt in that folder.
  4. Run this command (without the quotes): "git clone https://github.com/Snoothy/UCR ."
  5. Run this command: git fetch --all
  6. Run this command: git checkout -b origin/feature/plugingui-naming
  7. Run this command: git submodule update --init --recursive
  8. Open UCR/submodules/IOWrapper/IOWrapper.sln in Visual Studio 2022
  9. In Visual Studio 2022 go to: Tools > NuGet Package Manager > Package Manager Settings > Package Sources. Then add this source (without the quotes) (if not already there): "https://api.nuget.org/v3/index.json"
  10. Make sure the dropdown at the top is not "Debug" but instead "Release"
  11. Right click "Solution 'IOWrapper'" and choose "Build Solution"
  12. Exit Visual Studio 2022.
  13. Copy contents of "UCR\submodules\IOWrapper\Artifacts" to "UCR/dependencies" (need to make a new folder "dependencies")
  14. In Visual Studio 2022 go to: Tools > NuGet Package Manager > Package Manager Settings > Package Sources. Then add this source (without the quotes) (if not already there): "https://api.nuget.org/v3/index.json"
  15. Make sure the dropdown at the top is not "Debug" but instead "Release"
  16. Right click "Solution 'UCR'" and choose "Build Solution"
  17. You'll find the executable in "UCR\UCR\bin\Release"
  18. If there are any errors at this point, copy them and send them to me here.

Message ID: @.***>

Retroomer commented 7 months ago

I didn't really make that many changes but I could try to help you debug your build problems. First let's start over from scratch to make it easier for me to help you. Let me know the exact error message you get after following these instructions: 1. Download and install .NET 4.5.2 from: https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net452-developer-pack-offline-installer and .NET 4.6.1 from: https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net461-developer-pack-offline-installer 2. Create a new empty folder: e.g. c:/Projects/UCR 3. Open a command prompt in that folder. 4. Run this command (without the quotes): "git clone https://github.com/Snoothy/UCR ." 5. Run this command: git fetch --all 6. Run this command: git checkout -b origin/feature/plugingui-naming 7. Run this command: git submodule update --init --recursive 8. Open UCR/submodules/IOWrapper/IOWrapper.sln in Visual Studio 2022 9. In Visual Studio 2022 go to: Tools > NuGet Package Manager > Package Manager Settings > Package Sources. Then add this source (without the quotes) (if not already there): "https://api.nuget.org/v3/index.json" 10. Make sure the dropdown at the top is not "Debug" but instead "Release" 11. Right click "Solution 'IOWrapper'" and choose "Build Solution" 12. Exit Visual Studio 2022. 13. Copy contents of "UCR\submodules\IOWrapper\Artifacts" to "UCR/dependencies" (need to make a new folder "dependencies") 14. In Visual Studio 2022 go to: Tools > NuGet Package Manager > Package Manager Settings > Package Sources. Then add this source (without the quotes) (if not already there): "https://api.nuget.org/v3/index.json" 15. Make sure the dropdown at the top is not "Debug" but instead "Release" 16. Right click "Solution 'UCR'" and choose "Build Solution" 17. You'll find the executable in "UCR\UCR\bin\Release" 18. If there are any errors at this point, copy them and send them to me here. Message ID: @.***>

Thank you for the concise step-by-step guide. Your steps all worked on the first try and I've successfully built my own plugin now. Thank you!