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 not working with .NET 7 #773

Closed
OneCyrus opened this issue Dec 14, 2022 · 1 comment
Closed

CSharpier.MSBuild not working with .NET 7 #773

OneCyrus opened this issue Dec 14, 2022 · 1 comment
Milestone

Comments

@OneCyrus
Copy link

We are using CSharpier.MSBuild and running that in a .NET 7 container it still results in a .NET version issue

App: /root/.nuget/packages/csharpier.msbuild/0.21.0/tools/csharpier/dotnet-csharpier.dll
 Architecture: x64
 Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
 .NET location: /usr/share/dotnet/
 
 The following frameworks were found:
   7.0.1 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

 Learn about framework resolution:
 https://aka.ms/dotnet/app-launch-failed
 
 To install missing framework, download:
 https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=debian.11-x64
/root/.nuget/packages/csharpier.msbuild/0.21.0/build/CSharpier.MsBuild.targets(11,9): error MSB3073: The command "dotnet /root/.nuget/packages/csharpier.msbuild/0.21.0/build/../tools/csharpier/dotnet-csharpier.dll  --check /app/Shared" exited with code 150. [/app/Shared/Shared.csproj]
The command '/bin/sh -c dotnet publish ./PlatformRunner/PlatformRunner.csproj -c Release -o out' returned a non-zero code: 1
Error: Process completed with exit code 1.

we are using the mcr.microsoft.com/dotnet/sdk:7.0 image

as you can see it's actually using the 0.21.0 version of CSharpier but probably falls back as the MSBuild version is targeting .NET Standard. May be it needs to be multi targeted against .NET 7

belav added a commit that referenced this issue Dec 23, 2022
@belav
Copy link
Owner

belav commented Dec 23, 2022

I tracked this down to the CSharpier.MsBuild having a hardcoded path to a framework which was currently at net6.0.

I was able to modify it in a way that it will try to run CSharpier from the current target framework of the csproj it runs in. This can then be overridden with the following property <CSharpier_FrameworkVersion>net6.0</CSharpier_FrameworkVersion>.

One downside - without more work, anyone using CSharpier.MsBuild in a project targeting net48, netstandard2.0 etc will have to add the CSharpier_FrameworkVersion property. I don't know how common that is, so may just leave it as is for now.

@belav belav added this to the 0.22.0 milestone Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants