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

Version 4.3.0 breaks compilation due to NuGet packages with multiple Roslyn assemblies (e.g. System.Text.Json) #704

Open
tmak opened this issue Feb 19, 2025 · 1 comment

Comments

@tmak
Copy link

tmak commented Feb 19, 2025

Our Unity project has not compiled successfully on GitHub Actions since yesterday, when NuGetForUnity.Cli was auto-upgraded to 4.3.0.
When freezing our NuGetForUnity.Cli to 4.2.0, everything is working again.
Looking at the changelog of 4.3.0 this may be due to the changes introduced via #702.

Unity build error:

error CS9057: The analyzer assembly '/home/runner/work/unity-project/Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/System.Text.Json.SourceGeneration.dll' references version '4.4.0.0' of the compiler, which is newer than the currently running version '4.3.0.0'

Reducted Unity build log:

[1277/1477  0s] Csc Library/Bee/artifacts/2400b0aE.dag/CustomUnityAssembly.dll (+2 others)
##### CommandLine
"/home/runner/Unity/Hub/Editor/6000.0.31f1/Editor/Data/NetCoreRuntime/dotnet" exec "/home/runner/Unity/Hub/Editor/6000.0.31f1/Editor/Data/DotNetSdkRoslyn/csc.dll" /nostdlib /noconfig /shared "@Library/Bee/artifacts/2400b0aE.dag/CustomUnityAssembly.rsp" "@Library/Bee/artifacts/2400b0aE.dag/CustomUnityAssembly.rsp2"
##### Contents of Library/Bee/artifacts/2400b0aE.dag/CustomUnityAssembly.rsp
-target:library
-out:"Library/Bee/artifacts/2400b0aE.dag/CustomUnityAssembly.dll"
-refout:"Library/Bee/artifacts/2400b0aE.dag/CustomUnityAssembly.ref.dll"
-define:UNITY_6000_0_31
-define:UNITY_6000_0
-define:UNITY_6000
-define:UNITY_5_3_OR_NEWER
-define:UNITY_5_4_OR_NEWER
-define:UNITY_5_5_OR_NEWER
-define:UNITY_5_6_OR_NEWER
-define:UNITY_2017_1_OR_NEWER
-define:UNITY_2017_2_OR_NEWER
-define:UNITY_2017_3_OR_NEWER
-define:UNITY_2017_4_OR_NEWER
-define:UNITY_2018_1_OR_NEWER
-define:UNITY_2018_2_OR_NEWER
-define:UNITY_2018_3_OR_NEWER
-define:UNITY_2018_4_OR_NEWER
-define:UNITY_2019_1_OR_NEWER
-define:UNITY_2019_2_OR_NEWER
-define:UNITY_2019_3_OR_NEWER
-define:UNITY_2019_4_OR_NEWER
-define:UNITY_2020_1_OR_NEWER
-define:UNITY_2020_2_OR_NEWER
-define:UNITY_2020_3_OR_NEWER
-define:UNITY_2021_1_OR_NEWER
-define:UNITY_2021_2_OR_NEWER
-define:UNITY_2021_3_OR_NEWER
-define:UNITY_2022_1_OR_NEWER
-define:UNITY_2022_2_OR_NEWER
-define:UNITY_2022_3_OR_NEWER
-define:UNITY_2023_1_OR_NEWER
-define:UNITY_2023_2_OR_NEWER
-define:UNITY_2023_3_OR_NEWER
-define:UNITY_6000_0_OR_NEWER
-define:PLATFORM_ARCH_64
-define:UNITY_64
-define:UNITY_INCLUDE_TESTS
-define:ENABLE_AUDIO
-define:ENABLE_CACHING
-define:ENABLE_CLOTH
-define:ENABLE_MICROPHONE
-define:ENABLE_MULTIPLE_DISPLAYS
-define:ENABLE_PHYSICS
-define:ENABLE_TEXTURE_STREAMING
-define:ENABLE_VIRTUALTEXTURING
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.0/cs/ko/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.0/cs/pl/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.0/cs/pt-BR/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.0/cs/ru/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.0/cs/tr/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.0/cs/zh-Hans/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.0/cs/zh-Hant/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/System.Text.Json.SourceGeneration.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/cs/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/de/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/es/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/fr/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/it/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/ja/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/ko/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/pl/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/pt-BR/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/ru/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/tr/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/zh-Hans/System.Text.Json.SourceGeneration.resources.dll"
-analyzer:"Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/zh-Hant/System.Text.Json.SourceGeneration.resources.dll"
"Assets/_Framework/TestsSupport/Scripts/Runtime/ObservableTracker.cs"
-langversion:9.0
/deterministic
/optimize+
/debug:portable
/nologo
/RuntimeMetadataVersion:v4.0.30319
/nowarn:0169
/nowarn:0649
/nowarn:0282
/nowarn:1701
/nowarn:1702
-warnaserror+
-nowarn:0649
/utf8output
/preferreduilang:en-US
/additionalfile:"Library/Bee/artifacts/2400b0aE.dag/CustomUnityAssembly.UnityAdditionalFile.txt"
##### Custom Environment Variables
DOTNET_MULTILEVEL_LOOKUP=0
##### ExitCode
1
##### Output
error CS9057: The analyzer assembly '/home/runner/work/unity-project/Packages/nuget-packages/InstalledPackages/System.Text.Json.7.0.3/analyzers/dotnet/roslyn4.4/cs/System.Text.Json.SourceGeneration.dll' references version '4.4.0.0' of the compiler, which is newer than the currently running version '4.3.0.0'.

Packages/nuget-packages/NuGet.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
  <disabledPackageSources />
  <packageSourceCredentials />
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <config>
    <add key="packageInstallLocation" value="InPackagesFolder" />
    <add key="repositoryPath" value="./Packages" />
    <add key="PackagesConfigDirectoryPath" value="." />
    <add key="slimRestore" value="true" />
    <add key="PreferNetStandardOverNetFramework" value="true" />
  </config>
</configuration>

Reducted Packages/nuget-packages/NuGet.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Segment.Analytics.CSharp" version="2.5.0" manuallyInstalled="true" />
  <package id="Serialization.NET" version="1.4.1" />
  <package id="System.Text.Json" version="7.0.3" />
</packages>
@JoC0de
Copy link
Collaborator

JoC0de commented Feb 19, 2025

Thanks for creating the issue.
I was a litte bit curious as I changed the code in the PR.
I need to test it when I have some time. If you like you can test if it helps when you remove the line


that is added to the generated .meta files but propably we need logic that only adds the RoslynAnalyzer label for the analycers that use compatible compiler version.

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