0

I have a .NET project (previously developed in Visual Studio 2022, Windows) that is based on an sln solution that encompasses several subprojects. The structure is like:

  • App.PluginAdmin.sln
  • App.PluginAdmin/
    • App.PluginAdmin.csprog
    • Program.cs
    • ...
  • PluginBase/
    • PluginBase.csprog
    • Plugin.cs
    • ...
  • Plugins/
    • PluginOne/
      • PluginOne.csprog
      • Plugin.cs
      • ...
    • PluginTwo/
      • PluginTwo.csprog
      • Plugin.cs
      • ...
    • ...

While the App.PluginAdmin.sln solution is like:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32516.85
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App.PluginAdmin", "App.PluginAdmin\App.PluginAdmin.csproj", "{E7294DF7-4D11-4927-BA1B-8D1DE18643E1}"
    ProjectSection(ProjectDependencies) = postProject
        {0C027B86-6972-46DD-85B0-...} = {0C027B86-6972-46DD-85B0-...}
        {10C01D7F-1269-425F-ABE7-...} = {10C01D7F-1269-425F-ABE7-...}
        {15224486-DDDB-4A24-9BB5-...} = {15224486-DDDB-4A24-9BB5-...}
        {1A2A2546-A7E0-47D8-B3E7-...} = {1A2A2546-A7E0-47D8-B3E7-...}
    EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-...}") = "PluginBase", "PluginBase\PluginBase.csproj", "{DBFFB8B1-E30C-43A2-9B30-...}"
EndProject
Project("{2150E333-8FDC-42A3-...}") = "Plugins", "Plugins", "{FC7A31E0-F80B-4406-94A5-B4732A303C10}"
EndProject
Project("{9A19103F-16F7-4668-...}") = "PluginOne", "Plugins\PluginOne\PluginOne.csproj", "{B7C0DF85-D76E-42C0-8EBC-...}"
EndProject
Project("{9A19103F-16F7-4668-...}") = "PluginTwo", "Plugins\PluginTwo\PluginTwo.csproj", "{CC49BC06-0E8D-40DD-9222-...}"
EndProject
...
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {E7294DF7-4D11-...}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {E7294DF7-4D11-...}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {E7294DF7-4D11-...}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {E7294DF7-4D11-...}.Release|Any CPU.Build.0 = Release|Any CPU
        {DBFFB8B1-E30C-...}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {DBFFB8B1-E30C-...}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {DBFFB8B1-E30C-...}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {DBFFB8B1-E30C-...}.Release|Any CPU.Build.0 = Release|Any CPU
        {0C027B86-6972-...}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {0C027B86-6972-...}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {0C027B86-6972-...}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {0C027B86-6972-...}.Release|Any CPU.Build.0 = Release|Any CPU
        ...
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(NestedProjects) = preSolution
        {0C027B86-6972-...} = {64426B8E-3B99-...}
        {B7C0DF85-D76E-...} = {FC7A31E0-F80B-...}
        .....
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {5E4FC05C-...}
    EndGlobalSection
EndGlobal

Currently, I have to start the project on GNU/Linux in order to develop it from here. So I need to be able to launch the application from the terminal using commands. However, I don't know how to do it using the solution, since in Visual Studio it is very simple (choosing the solution and hitting play).

I have read here that I can use make to automate the compilation of all elements, but **how do I do this**? What would be the process? Doing dotnet buildeach project and then run it withdotnet run`?

I have tried to use cmake-converter like stated here:

cmake-converter -s ProjectingPlus.Monitor.sln

But I always get the output:

0.000037 processes count = 8
0.000062 warnings level = 2
0.044046 1> ERR  : Unknown project type at /home/user/git/App/ProjectingPlus.Monitor/ProjectingPlus.Monitor.csproj
0.044841 7> ERR  : Unknown project type at /home/user/git/App/Plugins/PluginOne/PluginOne.csproj
0.045149 8> ERR  : Unknown project type at /home/user/git/App/Plugins/PluginTwo/PluginTwo.csproj
.....
0.054685 Conversion of /home/user/git/App/App.PluginAdmin.sln finished
  • No need for cmake, use the [dotnet cli](https://learn.microsoft.com/en-us/dotnet/core/tools/). In the root of the project you want to start, simply type `dotnet run` (full documentation [here](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run)), it will compile your project, as well as any dependencies, fetch Nuget packages and run the program. CMake is for C/C++ not for C# – MindSwipe Nov 17 '22 at 09:58
  • @MindSwipe there are several projects (as seen in the structure), being `App.PluginAdmin`, `PluginBase` and many others within `Plugins`. In which should I do `dotnet run`? This is why they are included in a solution. – Fco Javier Balón Nov 17 '22 at 10:03
  • If I do it over what I consider to be the main project (`App.PluginAdmin`, which will call the rest), I get the error: `Unhandled exception. System.BadImageFormatException: Could not load file or assembly '/home/balon/git/proyecta/monitor4/BIN/netcoreapp3.1/ProjectingPlus.Monitor.dll'. An attempt was made to load a program with an incorrect format.` – Fco Javier Balón Nov 17 '22 at 10:04
  • You should to run whichever you want to run, I can't tell you which that is. As for the exception, it seems like your program is trying to load a DLL compiled for a wrong platform. Is `ProjectingPlus.Monitor.dll` compiled to Linux using the correct bitness (i.e 32bit or 64bit)? – MindSwipe Nov 17 '22 at 10:10

0 Answers0