Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSharpier.MSBuild uses TargetFramework to choose which CSharpier tool to run which results in odd behavior when building multi-target libraries in Microsoft container images #1022

Closed
adc-cjewett opened this issue Nov 16, 2023 · 0 comments · Fixed by #1034
Milestone

Comments

@adc-cjewett
Copy link

We use Microsoft's container images to build our code. CSharpier.MSBuild does not seem to play nicely with those images in more recent versions and the reason for that is it uses the TargetFramework to determine which version of the CSharpier tool is run. That seems incorrect because a machine with only .NET 8.0.100 SDK can build and package multi-target libraries. However, it cannot run .NET 6 or .NET 7 tools as the below error describes.

Would it make sense to expose a property that allows the users to override and specify which version of the CSharpier tool to be run?

Reproducible here: https://github.com/adc-cjewett/CSharpierTest

------
 > [build 1/1] RUN dotnet build "CSharpierTest.csproj" -c Release --no-restore:
0.633 MSBuild version 17.8.3+195e7f5a3 for .NET
1.456   You must install or update .NET to run this application.
1.457
1.457   App: /root/.nuget/packages/csharpier.msbuild/0.26.2/tools/csharpier/net7.0/dotnet-csharpier.dll
1.457   Architecture: x64
1.457   Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
1.457   .NET location: /usr/share/dotnet/
1.457
1.457   The following frameworks were found:
1.457     8.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
1.457
1.457   Learn more:
1.457   https://aka.ms/dotnet/app-launch-failed
1.457
1.457   To install missing framework, download:
1.457   https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=linux-x64&os=ubuntu.22.04
1.458 /root/.nuget/packages/csharpier.msbuild/0.26.2/build/CSharpier.MsBuild.targets(19,5): error MSB3073: The command "dotnet "/root/.nuget/packages/csharpier.msbuild/0.26.2/build/../tools/csharpier/net7.0/dotnet-csharpier.dll"  --check --no-msbuild-check "/CSharpierTest" > /dev/null " exited with code 150. [/CSharpierTest/CSharpierTest.csproj::TargetFramework=netstandard2.0]
1.719   You must install or update .NET to run this application.
1.720
1.720   App: /root/.nuget/packages/csharpier.msbuild/0.26.2/tools/csharpier/net6.0/dotnet-csharpier.dll
1.720   Architecture: x64
1.720   Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
1.720   .NET location: /usr/share/dotnet/
1.720
1.721   The following frameworks were found:
1.721     8.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
1.721
1.721   Learn more:
1.721   https://aka.ms/dotnet/app-launch-failed
1.721
1.721   To install missing framework, download:
1.721   https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=linux-x64&os=ubuntu.22.04
1.734 /root/.nuget/packages/csharpier.msbuild/0.26.2/build/CSharpier.MsBuild.targets(19,5): error MSB3073: The command "dotnet "/root/.nuget/packages/csharpier.msbuild/0.26.2/build/../tools/csharpier/net6.0/dotnet-csharpier.dll"  --check --no-msbuild-check "/CSharpierTest" > /dev/null " exited with code 150. [/CSharpierTest/CSharpierTest.csproj::TargetFramework=netstandard2.0]
3.540   CSharpierTest -> /CSharpierTest/bin/Release/net8.0/CSharpierTest.dll
3.563
3.564 Build FAILED.
3.565
3.565 /root/.nuget/packages/csharpier.msbuild/0.26.2/build/CSharpier.MsBuild.targets(19,5): error MSB3073: The command "dotnet "/root/.nuget/packages/csharpier.msbuild/0.26.2/build/../tools/csharpier/net7.0/dotnet-csharpier.dll"  --check --no-msbuild-check "/CSharpierTest" > /dev/null " exited with code 150. [/CSharpierTest/CSharpierTest.csproj::TargetFramework=netstandard2.0]
3.565 /root/.nuget/packages/csharpier.msbuild/0.26.2/build/CSharpier.MsBuild.targets(19,5): error MSB3073: The command "dotnet "/root/.nuget/packages/csharpier.msbuild/0.26.2/build/../tools/csharpier/net6.0/dotnet-csharpier.dll"  --check --no-msbuild-check "/CSharpierTest" > /dev/null " exited with code 150. [/CSharpierTest/CSharpierTest.csproj::TargetFramework=netstandard2.0]
3.565     0 Warning(s)
3.565     2 Error(s)
3.566
3.566 Time Elapsed 00:00:02.88
------
Dockerfile:12
--------------------
  10 |
  11 |     FROM restore AS build
  12 | >>> RUN dotnet build "CSharpierTest.csproj" -c Release --no-restore
--------------------
ERROR: failed to solve: process "/bin/sh -c dotnet build \"CSharpierTest.csproj\" -c Release --no-restore" did not complete successfully: exit code: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants