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

Issues switching from .NET SDK 6.0.x to 7.0.100 #29164

Closed
nietras opened this issue Nov 22, 2022 · 19 comments
Closed

Issues switching from .NET SDK 6.0.x to 7.0.100 #29164

nietras opened this issue Nov 22, 2022 · 19 comments
Assignees

Comments

@nietras
Copy link

nietras commented Nov 22, 2022

As a first step in migrating a .NET desktop (WPF,WinForms) application from .NET 6.0 to .NET 7.0 we have been simply switching to the new .NET SDK 7.0.100 by e.g. defining:

{
  "sdk": {
    "version": "7.0.100",
    "rollForward": "latestFeature",
    "allowPrerelease": false
  }
}

where version before was say 6.0.403. No other changes were made. However, this caused two sets of issues and we are wondering if these were expected, why and how to handle them properly. The two issues are:

  • Change in behavior when defining <PublishSingleFile>true</PublishSingleFile> in csproj
  • Change in code analysis rules causing errors

PublishSingleFile

This was a head scratcher. The solution in question will build an AnyCPU exe that works and runs on both x86 and x64. However, when switching to .NET SDK 7.0.100 this would not work. Either tests would simply not run with issues around bad format for the exe assembly or similar. Or if trying to run the exe project e.g. using F5 in visual studio this would simply crash upon start before anything with something like The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core."... code 2147516546 (0x80008082). As far as I can tell it turns out behavior has changed (silently) for PublishSingleFile so this now forces a RuntimeIdentifier (RID) to be set without any warning or similar. This causes the "format" of the output assembly to become platform specific e.g. win-x64 and hence trying to run x86 tests based on it will fail. Changing this definition to:

    <PublishSingleFile Condition="'$(RuntimeIdentifier)' != ''">true</PublishSingleFile>

resolved the issue. Guessing you should simply not define these options in csproj in the future if you have project that you want to build as Any CPU but instead do that only on command line when actually doing publish. Which means these often become redundantly defined.

Code Analysis Changes

This we don't understand. We have the following defined in Directory.Build.props with an accompanying .editorconfig next to sln at root of git repo.

    <AnalysisLevel>latest</AnalysisLevel>
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
    <RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
    <EnableNETAnalyzers>true</EnableNETAnalyzers>
    <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>

This compiled fine with zero errors using .NET 6.0 SDK. Switching to .NET SDK 7.0.100 and we had to define the following NoWarn to the solution building without errors. Note that the set of CAxxxx errors reported in VS and on command line are different this is the union of both to get both building.

    <NoWarn>
      $(NoWarn);
      CA1000;CA1001;CA1002;CA1003;CA1005;CA1008;CA1010;CA1012;CA1017;
      CA1021;CA1024;CA1028;CA1030;CA1031;CA1032;CA1036;
      CA1040;CA1043;CA1044;CA1045;CA1051;CA1052;CA1060;CA1062;CA1063;CA1065;CA1067;
      CA1304;CA1305;CA1307;CA1309;CA1310;CA1311;
      CA1401;CA1501;CA1506;CA1508;
      CA1707;CA1710;CA1711;CA1716;CA1720;CA1721;CA1724;CA1725;
      CA1802;CA1805;CA1810;CA1813;CA1814;CA1815;CA1816;CA1819;
      CA1820;CA1823;CA1825;CA1826;CA1829;CA1838;CA1850;CA1851;CA1852;
      CA2000;CA2007;CA2008;CA2101;CA2201;CA2208;CA2213;CA2214;CA2217;CA2225;CA2227;
      CA5392;CA5394
    </NoWarn>

that's a lot of new code analysis rules suddenly causing errors and this seems off, is this expected?

We would also the have expected to be able to set AnalysisLevel to 6.0 and get the 6.0 SDK behavior but this had no effect at all. Was this not the intended function of this property?

    <AnalysisLevel>6.0</AnalysisLevel>

Further technical details

  • Include the output of dotnet --info
 dotnet --info
.NET SDK:
 Version:   7.0.100
 Commit:    e12b7af219

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100\

Host:
  Version:      7.0.0
  Architecture: x64
  Commit:       d099f075e4

.NET SDKs installed:
  3.1.425 [C:\Program Files\dotnet\sdk]
  5.0.100 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  5.0.413 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]
  6.0.111 [C:\Program Files\dotnet\sdk]
  6.0.203 [C:\Program Files\dotnet\sdk]
  6.0.306 [C:\Program Files\dotnet\sdk]
  6.0.400 [C:\Program Files\dotnet\sdk]
  6.0.403 [C:\Program Files\dotnet\sdk]
  7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]
  7.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  arm64 [C:\Program Files\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation]
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version

Visual Studio 17.5.0 Preview 1.0

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Install untriaged Request triage from a team member labels Nov 22, 2022
@nietras
Copy link
Author

nietras commented Nov 23, 2022

Example of code analysis rules that do not cause errors in Visual Studio 17.5.0 Preview 1.0 but does when running dotnet build on command line are e.g. CA1012, CA1005, CA1002 and others. Why is that?

@Youssef1313
Copy link
Member

@mavasani Is this related to the issue you fixed recently?

@nietras
Copy link
Author

nietras commented Nov 24, 2022

This is getting out of hand. We are now seeing .NET SDK 6.0.xyz builds failing on CI machines after .NET SDK 7.0 has been installed in e.g. _tool (we use Azure DevOps). Hence, already existing builds are now failing due to this SDK being installed!

@nietras
Copy link
Author

nietras commented Nov 24, 2022

Forget the last part that appears to have been our own mistake because we defined global.json with rollForward: latestMajor, I see now that was a big mistake given SDK clearly can break things vis-a-vis code analyzers.

@eerhardt
Copy link
Member

PublishSingleFile
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core."... code 2147516546 (0x80008082)

cc @vitek-karas @agocke. @nietras - Maybe that issue should be spun off into a separate issue in dotnet/runtime? We want people to set the PublishXXX properties (like PublishAot, PublishTrimmed, etc.) in their .csproj up-front.

@mavasani
Copy link
Contributor

@mavasani Is this related to the issue you fixed recently?

Nope, that was the reverse problem where code analysis rules are not getting enabled.

@nietras Can you try to set the AnalysisMode property in your props/targets to default and see if that changes the code analysis warnings in your build output: https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#analysismode? All the CAxxxx rules defined in your NoWarn should be disabled by default on builds, so something must be turning it on.

@vitek-karas
Copy link
Member

PublishSingleFile
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core."... code 2147516546 (0x80008082)

This is a known issue (now, we figure it out really late unfortunately) - there's a discussion on the problem and potential fixes here: #29031. Your analysis is spot on - the SDK changed to default RID pretty much always.

As @eerhardt noted - we want you to set PublishXXX in the csproj, since that property has multiple effects - some of which should be visible even in normal builds. For example it enables additional analyzers (but none of the warnings you listed above are from those analyzers, so you're not seeing issues because of that) and it can modify behavior (single-file doesn't do this, but for example PublishTrimmed will disable some functionality by default - like built-in COM, even in dotnet build).

I'm interested in how this worked for you on 6 though. If the app targets net6.0 even dotnet build produces an .exe which is platform specific (it defaults to the RID of the SDK being used). .NET 6 can't produce architecture agnostic exes - only .NET Framework can do that. So if you already relied on running the .exe directly it should have been broken even on .NET 6. What worked (and should mostly still work) is to run the app via dotnet app.dll in which case the architecture is chosen by running the right dotnet for that architecture. The above mentioned SDK change does break this, but only for apps which carry native dependencies and in that case the error would look different.

@nietras
Copy link
Author

nietras commented Nov 29, 2022

Can you try to set the AnalysisMode property in your props/targets to default

@mavasani setting AnalysisMode to default or even none has no effect on the code analysis errors when removing NoWarns. E.g.:

    <AnalysisLevel>latest</AnalysisLevel>
    <AnalysisMode>none</AnalysisMode>
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
    <RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
    <EnableNETAnalyzers>true</EnableNETAnalyzers>
    <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>

using compound AnalysisLevel e.g. <AnalysisLevel>6-none</AnalysisLevel> did have an effect but still some errors occur that did not occur with .NET SDK 6 e.g. CA1823. However, setting <AnalysisLevel>latest-default</AnalysisLevel> would still error on e.g. CA1825. And <AnalysisLevel>latest-none</AnalysisLevel> does not change that. Which I find puzzling.

All the CAxxxx rules defined in your NoWarn should be disabled by default on builds, so something must be turning it on.

Yes, this definitely seems to be the case, as I am working through each CA and updating an .editorconfig (next to sln at git repo root) I also started noticing that some CA's cannot be disabled via .editorconfig but instead have to be disable via NoWarn in Directory.Build.props. For example, the following in .editorconfig will not fully disabled these CAs and they still cause build errors.

# CA1501: Avoid excessive inheritance
dotnet_diagnostic.CA1501.severity = none
# CA1506: Avoid excessive class coupling
dotnet_diagnostic.CA1506.severity = none
# CA1724: Type names should not match namespaces
dotnet_diagnostic.CA1724.severity = none
# CA1810: Initialize reference type static fields inline
dotnet_diagnostic.CA1810.severity = none

Additionally, I noticed settings severity to suggestion will also still cause build errors, which surprised me since I would assume only warning would be treated as error with <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>.

To try to understand I tried to look at how the analyzers severity was defined packaged .editorconfig files in .NET SDK 6.0.403 vs .NET SDK 7.0.100 by simply comparing the two directories C:\Program Files\dotnet\sdk\6.0.403\Sdks\Microsoft.NET.Sdk\analyzers\build\config\ and C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk\analyzers\build\config\. I was surprised to see:

image

  • Both analysis level 5 and 6 files have been changed, mainly a change of global_level = -2 to e.g. global_level = -100 or similar. Not sure what impact this could have. But also that new CA's could be added, perhaps that just new analysis rules.
  • There's no analysis level 7 files in .NET SDK 7.0.100. Just for my understanding why is that not the case? Based on https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#analysislevel quoted below, which states " Each .NET release, starting in .NET 5, has a set of code analysis rules. " I would assume there should be set for .NET 7. Of course, this also says setting to 6 would give me the set of rules from .NET 6 but that clearly didn't work either. :)

    The AnalysisLevel property lets you specify a set of code analyzers to run according to a .NET release. Each .NET release, starting in .NET 5, has a set of code analysis rules. Of that set, the rules that are enabled by default for that release will analyze your code. For example, if you upgrade to .NET 7 but don't want the default set of code analysis rules to change, set AnalysisLevel to 6.

I'm interested in how this worked for you on 6 though. If the app targets net6.0 even dotnet build produces an .exe which is platform specific (it defaults to the RID of the SDK being used). .NET 6 can't produce architecture agnostic exes - only .NET Framework can do that. So if you already relied on running the .exe directly it should have been broken even on .NET 6.

@vitek-karas it does produce an exe file (and also project has TFM .net6.0-windows), why does the exe have to be arch. specific if it is runtime/framework dependent on Windows? (dumb question probably, but want to be sure I understand).

However the dll next to it should not be, could that then change if RID is forced in new SDK for this output? I then assume the exe is not used by projects referencing the exe-project but only the dll output then, and changes to that can then trigger the crash during startup or testing. Not sure how this relates to F5 runs then though?

already relied on running the .exe directly

I may have given a confusing description in issue. We don't rely on running the exe-directly but:

trying to run the exe project e.g. using F5 in visual studio

and hence the below is probably wrong on my part:

solution in question will build an AnyCPU exe that works and runs on both x86 and x64

As that claims something that assumes the exe is involved in the runs from VS and running test projects that reference the exe-project using mstest for both x86 and x64 like we do. This worked in .NET 6 but not .NET 7 with PublishSingleFile so perhaps in .NET 7 there are changes to the dll being output next to the exe which wasn't the case before?

@nietras
Copy link
Author

nietras commented Nov 29, 2022

A little side note also discovered a rule CA1852 that is "undocumented" below link will fail can can't google it:

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1852

Severity	Code	Description	Project	File	Line	Suppression State
Error	CA1852	Type 'XYZ' can be sealed because it has no subtypes in its containing assembly and is not externally visible WWW

and I hit the top-level statement issue here too:

dotnet/runtime#78270 "Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible"

@vitek-karas
Copy link
Member

I don't think the dll is affected by the RID (it shouldn't be) - as noted above it would have effect on apps which have native dependencies, but the error would be different in that case. I think what's happening is that dotnet run (and F5 which is similar) does change behavior if there's RID versus no RID, but I'm not sure.

Re why .exe is not architecture agnostic: Native executables are inherently architecture specific, that's true basically everywhere. In .NET Framework though, the .exe it produces is not a native executable, it's a managed assembly. For that to work the OS (Windows) has a piece of code which runs very early on when starting a new process, which looks at the .exe and if it's a managed assembly, it calls into the .NET Framework to run it. Since this happens very early on, the .NET Framework code gets to decide which architecture it should run on -> it works on all architectures. But for this to work, .NET Framework must be part of the operating system effectively (which it is). With .NET Core we really didn't want this coupling with the OS (as it makes it difficult to iterate for us), and in addition, such functionality is not available on Linux/mac, where .NET Core works as well. So we intentionally dropped this functionality and the .exe you get for a .NET Core app is a normal native executable (just like any other compiler produces), which must be architecture specific. In .NET Core if you want a portable app (architecture and platform agnostic), you build it without specifying RID and you run it via dotnet app.dll.

@mavasani
Copy link
Contributor

@nietras Can you also try and add an explicit NuGet package reference to https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet7/NuGet/Microsoft.CodeAnalysis.NetAnalyzers/versions and see if fixes the Code analysis issue? Otherwise, it would make sense to split apart the Code analysis part of this issue into a separate issue in roslyn-analyzers repo. Thanks.

@nietras
Copy link
Author

nietras commented Nov 29, 2022

the .exe you get for a .NET Core app is a normal native executable (just like any other compiler produces)

@vitek-karas thanks for the explanation that fits with my understanding after all then, sorry about the confusing description.

I think what's happening is that dotnet run (and F5 which is similar) does change behavior if there's RID versus no RID, but I'm not sure.

That would would seem likely, but could this not be due to PlatformTarget being set in .NET 7 while it wasn't in .NET 6? Hence, dll gets an incompatible platform target? It should be fairly simple to check this right?


Can you also try and add an explicit NuGet package reference to https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet7/NuGet/Microsoft.CodeAnalysis.NetAnalyzers/versions and see if fixes the Code analysis issue?

@mavasani added below to bottom of Directory.Build.props and did not see observe any change to CA errors.

  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0-preview1.22559.1" />
  </ItemGroup>

added <add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" /> to nuget.config.

Otherwise, it would make sense to split apart the Code analysis part of this issue into a separate issue in roslyn-analyzers repo. Thanks.

I am not privy to where this might be best resolved just let me know what you think and open issues accordingly.

@vitek-karas
Copy link
Member

That would would seem likely, but could this not be due to PlatformTarget being set in .NET 7 while it wasn't in .NET 6? Hence, dll gets an incompatible platform target? It should be fairly simple to check this right?

It could be that PlatformTarget of the dll - but I doubt it. For example the missing runtime start event error - the runtime start event should fire before the runtime even tries to load the dll. But again, I haven't played with it. The real fix is what is described in the referred PR, it sort of doesn't matter why it fails exactly as it should never get into that situation.

@christianduerselen
Copy link

@nietras Can you also try and add an explicit NuGet package reference to https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet7/NuGet/Microsoft.CodeAnalysis.NetAnalyzers/versions and see if fixes the Code analysis issue? Otherwise, it would make sense to split apart the Code analysis part of this issue into a separate issue in roslyn-analyzers repo. Thanks.

I believe roslyn-analyzers/issues/6281 already has this issue covered? Hoping for feedback on this issue and whether it's a regression between .NET 6 and 7.

nagilson added a commit to dotnet/docs that referenced this issue Nov 29, 2022
The additional information is included above. We didn't expect RID Inference to be a breaking change but there were after-effects, like here: dotnet/sdk#29164 or here dotnet/sdk#29177
@nagilson
Copy link
Member

As far as I can tell it turns out behavior has changed (silently) for PublishSingleFile so this now forces a RuntimeIdentifier (RID) to be set without any warning or similar.

That is correct, dotnet/docs#32784 will add it to the breaking change list. Thanks!

@martincostello
Copy link
Member

I just bumped into the CA1852 false-positive (#29164 (comment)) upgrading from 7.0.100 to 7.0.101 in an app with a top-level program:

Error: /Users/runner/work/httpclient-interception/httpclient-interception/samples/SampleApp/Program.cs(9,1): error CA1852: Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible [/Users/runner/work/httpclient-interception/httpclient-interception/samples/SampleApp/SampleApp.csproj]

@Youssef1313
Copy link
Member

@martincostello This is fixed in dotnet/roslyn-analyzers#6278

@nagilson
Copy link
Member

@nietras We are wrapping up the work to fix the aforementioned PublishSingleFile issue. It would help us verify and understand your situation better if you could provide a binlog for the successful 6.0 SDK and unsuccessful 7.0 SDK build. Is that something you're OK with? Thanks!

Also, this has been documented here due to this issue: https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/7.0/automatic-runtimeidentifier

@nagilson
Copy link
Member

nagilson commented Jan 4, 2023

I expect the other component with publishing to be fixed in 7.0.200. Will close this soon if there's no more correspondence.

@nagilson nagilson removed the untriaged Request triage from a team member label Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants