OPCFoundation / UA-ModelCompiler

ModelCompiler converts XML files into C# and ANSI C
MIT License
151 stars 94 forks source link

problem running msbuild on Linux #100

Closed danmoser closed 2 years ago

danmoser commented 2 years ago

I am getting the following error when running msbuild "ModelCompiler Solution.sln" /p:TargetFrameworkVersion="v4.5"

Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 12/07/2021 18:52:20.
Project "/home/root/UA-ModelCompiler/ModelCompiler Solution.sln" on node 1 (default targets).
ValidateSolutionConfiguration:                                                                               
  Building solution configuration "Debug|Mixed Platforms".
Project "/home/root/UA-ModelCompiler/ModelCompiler Solution.sln" (1) is building "/home/root/UA-ModelCompiler/Tests/DemoModel/DemoModel.csproj" (2) on node 1 (default targets).                                          
/usr/lib/mono/msbuild/Current/bin/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1004: Assets file '/home/root/UA-ModelCompiler/Tests/DemoModel/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/root/UA-ModelCompiler/Tests/DemoModel/DemoModel.csproj]
Done Building Project "/home/root/UA-ModelCompiler/Tests/DemoModel/DemoModel.csproj" (default targets) -- FAILED.
Project "/home/root/UA-ModelCompiler/ModelCompiler Solution.sln" (1) is building "/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj" (3) on node 1 (default targets).
Project "/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj" (3) is building "/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj" (3:2) on node 1 (Build target(s)).
/usr/lib/mono/msbuild/Current/bin/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1004: Assets file '/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj]
Done Building Project "/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj" (Build target(s)) -- FAILED.
Done Building Project "/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj" (default targets) -- FAILED.
Done Building Project "/home/root/UA-ModelCompiler/ModelCompiler Solution.sln" (default targets) -- FAILED.

Build FAILED.

"/home/root/UA-ModelCompiler/ModelCompiler Solution.sln" (default target) (1) ->
"/home/root/UA-ModelCompiler/Tests/DemoModel/DemoModel.csproj" (default target) (2) ->
(ResolvePackageAssets target) -> 
  /usr/lib/mono/msbuild/Current/bin/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1004: Assets file '/home/root/UA-ModelCompiler/Tests/DemoModel/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/root/UA-ModelCompiler/Tests/DemoModel/DemoModel.csproj]

"/home/root/UA-ModelCompiler/ModelCompiler Solution.sln" (default target) (1) ->
"/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj" (default target) (3) ->
"/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj" (Build target) (3:2) ->
  /usr/lib/mono/msbuild/Current/bin/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1004: Assets file '/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj]

    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:00.91

Any ideas?

mregen commented 2 years ago

Hi @danmoser , this is now a .NET 5.0 project. Try to build it using dotnet tools with .NET 5 SDK installed. e.g. dotnet build "ModelCompiler Solution.sln"

danmoser commented 2 years ago

Hi @mregen , thanks for the reply. With .NET 5 SDK installed, I got the following errors

Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /home/root/UA-ModelCompiler/Tests/DemoModel/DemoModel.csproj (in 11.4 sec).
  Restored /home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj (in 11.4 sec).
/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/NodeDocumentationReader.cs(5,7): error CS0246: The type or namespace name 'CsvHelper' could not be found (are you missing a using directive or an assembly reference?) [/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj]                        
/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/NodeDocumentationReader.cs(7,7): error CS0246: The type or namespace name 'CsvHelper' could not be found (are you missing a using directive or an assembly reference?) [/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj]                        
/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/NodeDocumentationReader.cs(8,7): error CS0246: The type or namespace name 'CsvHelper' could not be found (are you missing a using directive or an assembly reference?) [/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj]   
(...)
/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/NodeDocumentationReader.cs(76,48): error CS0246: The type or namespace name 'ClassMap<>' could not be found (are you missing a using directive or an assembly reference?) [/home/root/UA-ModelCompiler/Opc.Ua.ModelCompiler/Opc.Ua.ModelCompiler.csproj]
    0 Warning(s)
    18 Error(s)
opcfoundation-org commented 2 years ago

You need to restore NuGet packages.

opcfoundation-org commented 2 years ago

Pushed an update with the correct NuGets linked.

danmoser commented 2 years ago

Thanks @opcfoundation-org . Now the command dotnet build "ModelCompiler Solution.sln" worked successfully.