Currently the package ros2cs_tests does not set CSHARP_TARGET_FRAMEWORK in cmake leading to the default version being used which can cause unexpected build failures in case of upgrades.
The latest commit in the cmake module for C# changed the default version from netcoreapp3.1 to netstandard2.0 causing the following build failure on Ubuntu 22.04 and Windows 10 with ROS2 Humble:
C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj : warning NU1701: Package 'NUnit3TestAdapter 3.11.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj : warning NU1701: Package 'xunit.runner.visualstudio 2.4.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
All projects are up-to-date for restore.
C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj : warning NU1701: Package 'NUnit3TestAdapter 3.11.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj : warning NU1701: Package 'xunit.runner.visualstudio 2.4.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
CSC : warning CS1668: Invalid search path 'lib\um\x64' specified in 'LIB environment variable' -- 'directory does not exist' [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(66,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(81,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(101,17): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(123,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(148,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(184,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
Build FAILED.
C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj : warning NU1701: Package 'NUnit3TestAdapter 3.11.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj : warning NU1701: Package 'xunit.runner.visualstudio 2.4.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj : warning NU1701: Package 'NUnit3TestAdapter 3.11.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj : warning NU1701: Package 'xunit.runner.visualstudio 2.4.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
CSC : warning CS1668: Invalid search path 'lib\um\x64' specified in 'LIB environment variable' -- 'directory does not exist' [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(66,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(81,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(101,17): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(123,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(148,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
C:\dev\ros2-for-unity\src\ros2cs\src\ros2cs\ros2cs_tests\src\ClientTest.cs(184,13): error CS8370: Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests\ros2cs_tests_dotnetcore.csproj] [C:\dev\ros2-for-unity\src\ros2cs\build\ros2cs_tests\ros2cs_tests.vcxproj]
5 Warning(s)
6 Error(s)
I suggest setting it to netcoreapp6.0 since the the tests are not distributed as far as I know and netcoreapp3.1 requires dotnet 3.1 which is not available on ubuntu 22.04.
If you agree I could make a PR and update the Windows / Ubuntu Readme.
Currently the package
ros2cs_tests
does not setCSHARP_TARGET_FRAMEWORK
in cmake leading to the default version being used which can cause unexpected build failures in case of upgrades.The latest commit in the cmake module for C# changed the default version from
netcoreapp3.1
tonetstandard2.0
causing the following build failure on Ubuntu 22.04 and Windows 10 with ROS2 Humble:I suggest setting it to
netcoreapp6.0
since the the tests are not distributed as far as I know andnetcoreapp3.1
requires dotnet 3.1 which is not available on ubuntu 22.04.If you agree I could make a PR and update the Windows / Ubuntu Readme.