ukrishnas / LPSharp

LP solvers for optimization problems in C#, .Net, Windows platforms
MIT License
0 stars 0 forks source link

Build fails with dotnet command not found #2

Closed ukrishnas closed 3 months ago

ukrishnas commented 3 months ago

When I build either GLOP or CLP CoinWrap, CMake fails with the following error messages. How can I fix it?

  Generating dotnet/Google.OrTools.Glop.runtime.win-x64/Google.OrTools.Glop.runtime.win-x64.csproj
  Generate or-tools.snk using CreateSigningKey project
  Could not execute because the application was not found or a compatible .NET SDK is not installed.
  Possible reasons for this include:
    * You intended to execute a .NET program:
        The application 'run' does not exist.
    * You intended to execute a .NET SDK command:
        It was not possible to find any installed .NET SDKs.
        Install a .NET SDK from:
          https://aka.ms/dotnet-download
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(240,5
): error MSB8066: Custom build for 'D:\Experiments\LPSharp\GLOP\build\CMakeFiles\0e779a359966f3c3227aac3a3f626525\Googl
e.OrTools.Glop.runtime.win-x64.csproj.rule;D:\Experiments\LPSharp\GLOP\build\CMakeFiles\282233727f23cb55b682671dc6ae9f3
1\or-tools.snk.rule;D:\Experiments\LPSharp\GLOP\build\CMakeFiles\d1c9762c8a164990df76129f4be8aceb\dotnet_native_package
.rule' exited with code -2147450735. [D:\Experiments\LPSharp\GLOP\build\dotnet_native_package.vcxproj]
  Generating dotnet/CoinOr.Clp.runtime.win-x64/CoinOr.Clp.runtime.win-x64.csproj
  Could not execute because the application was not found or a compatible .NET SDK is not installed.
  Possible reasons for this include:
    * You intended to execute a .NET program:
        The application 'build' does not exist.
    * You intended to execute a .NET SDK command:
        It was not possible to find any installed .NET SDKs.
        Install a .NET SDK from:
          https://aka.ms/dotnet-download
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(240,5
): error MSB8066: Custom build for 'D:\Experiments\LPSharp\CLP\CoinWrap\build\CMakeFiles\5c1befcf6e9060b999e975b84780cd
dc\CoinOr.Clp.runtime.win-x64.csproj.rule;D:\Experiments\LPSharp\CLP\CoinWrap\build\CMakeFiles\add9fae56b76db71aaf444f1
ab9838c2\coinwrap_native_package.rule' exited with code -2147450735. [D:\Experiments\LPSharp\CLP\CoinWrap\build\coinwra
p_native_package.vcxproj]
ukrishnas commented 3 months ago

Looks like you did not install an SDK with dotnet. From a command prompt execute, the following commands.

Broken:

$ where dotnet
C:\Program Files (x86)\dotnet\dotnet.exe
C:\Program Files\dotnet\dotnet.exe

$ dotnet --list-sdks
<nothing>

Working:

$ where dotnet
C:\Program Files\dotnet\dotnet.exe
$ dotnet --list-sdks
5.0.401 [C:\Program Files\dotnet\sdk]

In my reproduction of the problem, I had an incompletely installed dotnet in C:\Program Files (x86)\dotnet that had no sdk folder.

A more basic reason could be you do not have dotnet. Dotnet comes automatically with a Visual Studio installation. But if you have neither, then you need to install dotnet from https://aka.ms/dotnet-download. The name changes of dotnet can be confusing. You need .NET N.0 SDK where N = 5, 6 7, 8, ... (whatever is the latest; you need the SDK and it comes with the runtime). .NET N.0 (N >= 5) is the unified dotnet, and you can purge your mind of previous flavors like Framework and Core.