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 does not support DotNet 8 #1012

Closed
aa-dit-yuh opened this issue Nov 15, 2023 · 4 comments · Fixed by #1013
Closed

CSharpier.MsBuild does not support DotNet 8 #1012

aa-dit-yuh opened this issue Nov 15, 2023 · 4 comments · Fixed by #1013
Milestone

Comments

@aa-dit-yuh
Copy link
Contributor

aa-dit-yuh commented Nov 15, 2023

Targets within the CSharpier.MsBuild project fail to run when the target framework is set to DotNet 8 while Dotnet SDK v7 is not installed on the host

How to replicate:

  1. Ensure DotNet SDK v8 is the only SDK version available.

    winget uninstall Microsoft.DotNet.SDK.7
    winget install Microsoft.DotNet.SDK.8
    
  2. Modify the file CSharpier.MsBuild.Test.csproj:

    • Change the TargetFramework to net8.0
  3. Build the CSharpier.MsBuild.Test project with Release configuration

    cd Src/CSharpier.MsBuild.Test
    dotnet build -c Release
    

I see the following output:

MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  You must install or update .NET to run this application.

  App: C:\Users\adnarayan\.nuget\packages\csharpier.msbuild\0.26.0\tools\csharpier\net7.0\dotnet-csharpier.dll
  Architecture: x64
  Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
  .NET location: C:\Program Files\dotnet\

  The following frameworks were found:
    3.1.32 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    6.0.24 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    8.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

  Learn more:
  https://aka.ms/dotnet/app-launch-failed

  To install missing framework, download:
  https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=win-x64&os=
  win10
C:\Users\adnarayan\.nuget\packages\csharpier.msbuild\0.26.0\build\CSharpier.MsBuild.targets(19,5): error MSB3073: The c
ommand "dotnet "C:\Users\adnarayan\.nuget\packages\csharpier.msbuild\0.26.0\build\../tools/csharpier/net7.0/dotnet-csha
rpier.dll"  --check --no-msbuild-check "C:\Users\adnarayan\source\csharpier\Src\CSharpier.MsBuild.Test" > NUL " exited
with code -2147450730. [C:\Users\adnarayan\source\csharpier\Src\CSharpier.MsBuild.Test\CSharpier.MsBuild.Test.csproj::T
argetFramework=net8.0]

Build FAILED.

C:\Users\adnarayan\.nuget\packages\csharpier.msbuild\0.26.0\build\CSharpier.MsBuild.targets(19,5): error MSB3073: The c
ommand "dotnet "C:\Users\adnarayan\.nuget\packages\csharpier.msbuild\0.26.0\build\../tools/csharpier/net7.0/dotnet-csha
rpier.dll"  --check --no-msbuild-check "C:\Users\adnarayan\source\csharpier\Src\CSharpier.MsBuild.Test" > NUL " exited
with code -2147450730. [C:\Users\adnarayan\source\csharpier\Src\CSharpier.MsBuild.Test\CSharpier.MsBuild.Test.csproj::T
argetFramework=net8.0]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.81
@aa-dit-yuh
Copy link
Contributor Author

Can we another minor version release to push this commit to Nuget. This bug prevents upgrade to DotNet 8 within any project that depends on CSharpier.Msbuild.

@belav
Copy link
Owner

belav commented Nov 16, 2023

@aditnryn yeah I was planning on getting a release out soon. I'm trying to get a GH action set up to test this type of setup, and it seems like your fix may not be working - https://github.com/belav/csharpier/actions/runs/6886037708/job/18731089563?pr=1017#step:4:154

An easy workaround is to add <CSharpier_FrameworkVersion>net8.0</CSharpier_FrameworkVersion> to your project. I had to do it for the net48 and net7.0 projects in this action. I'm debating if I set up all the different situations, but it probably isn't worth it.

I'm going to see if I can figure out if my action isn't testing it correctly or if there is something else missing. Your PR looked like it should be working.

@belav
Copy link
Owner

belav commented Nov 16, 2023

Yeah, something weird is going on. The new version starts with CSharpier_Framework version empty.
image

@belav
Copy link
Owner

belav commented Nov 16, 2023

That was a red herring, but I did eventually figure this out. It isn't clear why, but without passing CSharpier_FrameworkVersion=$(CSharpier_FrameworkVersion) to CSharpierFormatInner the new version you have seems to lose the target framework, which results in it defaulting back to net7.0

@belav belav added this to the 0.26.2 milestone Nov 16, 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
2 participants