In order to migrate the C# project to NET Standard 2.0, I followed the advices here. I used the NET upgrade-assistant CLI tool to convert the legacy C# csproj file to NET Standard 2.0. This process also created a new SDK style csproj file. Furthermore, I upgraded the managed NET Framework project from 4.0 to 4.7.2. to take advantage of the NET Framework Compatibility mode, see here.
After finalizing these steps, I could successfully build all projects using Visual Studio 2022 and MSBuild 17.0 (3 dlls were created for each of the projects - as it used to be before the NET Standard 2.0 migration).
However, the build process shall work using a Visual Studio 2017 / MSBuild 15.0 environment. When building the projects with VS 2017 I get the following error:
C:\Program Files\dotnet\sdk\2.1.202\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(114,5): error : Cannot find project info for 'Unmanaged.vcxproj'. This can indicate a missing project reference.
When compiling in the console in verbose mode, it gives some more information. It seems to have to do with the Target "GenerateBuildDependencyFile" which is part of the "NET.Sdk.targets" automatically invoked by the new SDK style project file and the creation of a "CSharpLib.deps.json" file.
This is the crucial difference in the build log compiling with VS2022/MSBuild17 and VS2017/MSBuild15:
VS2022:
Building target "GenerateBuildDependencyFile" completely.
Output file "CSharp.deps.json" does not exist.
Using "GenerateDepsFile" task from assembly "C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\..\tools\net472\Microsoft.NET.Build.Tasks.dll".
Task "GenerateDepsFile"
Done executing task "GenerateDepsFile".
Eventually, here a "CSharpLib.deps.json" is located in the build output folder after the build.
VS2017:
Building target "GenerateBuildDependencyFile" completely.
Output file "CSharp.deps.json" does not exist.
Using "GenerateDepsFile" task from assembly "C:\Program Files\dotnet\sdk\2.1.202\Sdks\Microsoft.NET.Sdk\build\..\tools\net46/Microsoft.NET.Build.Tasks.dll".
Task "GenerateDepsFile"
C:\Program Files\dotnet\sdk\2.1.202\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(114,5): error : Cannot find project info for 'Unmanaged.vcxproj'. This can indicate a missing project reference. [CSharp.csproj]
Done executing task "GenerateDepsFile" -- FAILED.
Done building target "GenerateBuildDependencyFile" in project "CSharp.csproj" -- FAILED.
Here no "CSharpLib.deps.json" is located in the build output folder after the build.
Can anybody give a hint what the reason could be that I cannot build the C# project using VS 2017? Thanks a lot, David
I expect the C# project to successfully compile using VS 2017, MSBuild 15.0.