format: dotnet format is broken on sdk 7.0.200 if `EnforceCodeStyleInBuild` is set to `true` – Could not load file or assembly 'Microsoft.CodeAnalysis'
step to reproduce
- create new project
dotnet new console
-
add
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>to .csproj -
add global.json
dotnet new globaljson
- change sdk version in global.json to “7.0.103”
- run
dotnet format
everything is ok here.
- change sdk version in global.json to “7.0.200”
- run
dotnet format
and now there are a lot of
Unhandled exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
in output
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 36
- Comments: 28 (7 by maintainers)
Commits related to this issue
- Use .NET 7.0.103 (#170) As usual, `dotnet format` is broken on .NET 7.0.200 (see https://github.com/dotnet/format/issues/1800). We'll install the latest of 7.0.100 for now. — committed to craigktreasure/SlnUp by craigktreasure a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- use 7.0.203 due to format failing More info: https://github.com/dotnet/format/issues/1800 — committed to JohnnyCrazy/SpotifyAPI-NET by JohnnyCrazy a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
- Downgrade Microsoft.CodeAnalysis to 4.4.0 This is a workaround to fix issues with dotnet-format. See: - https://github.com/dotnet/format/issues/1805 - https://github.com/dotnet/format/issues/1800 — committed to TSRBerry/Ryujinx by TSRBerry a year ago
Is there any Road Map for fixing this issue?
.NET 7.0.4 is installed automatically with Visual Studio 2022 and for the past 4 months bundled dotnet-format is unusable. #1782 Seems to be forgotten.
This seems to be an issue on 7.0.202 and 7.0.203 as well.
First off, apologies for the delays in getting this fixed! We have had bit of personnel churn in this space, but we have a fix checked in on the format side now and it is queued up to catch the next SDK servicing train that is currently planned for 7.0.3xx .NET SDK. I will circle back once I have a confirmation that the fix has been released. In the interim, dropping down to 7.0.2xx to use the dotnet format would be the temporary workaround.
Thanks for that! Is there any way to get automated tests for this? I think this is the second or third time dotnet format has broken completely since 6.0 for roughly the same reason.
#1825 Merged
Both this problem and dotnet/sdk#32598 seem to have been fixed in sdk 7.0.304. I re-enabled EnforceCodeStyleInBuild, removed all workarounds and downgrades which I had been using for 4 months and can once again enjoy
dotnet formatas is. Hope it’s not just me. Thank you!@avidenic .NET8 also
@RikkiGibson Do you know if there are plans to assign a new maintainer to this project?
I suspect that this is caused by dotnet-format’s reference to the compiler getting out of date. #1782
@arkalyanms when will this be fixed? This has been broken for months.
I’ve been getting this using .NET 8 in a dev container where .NET was installed using
dotnet-install.sh.The project it runs into an exception while trying to format is an Incremental Source Generator.
Solution: https://github.com/LorettaDevs/Loretta (devcontainer files are contained within) Project:
Loretta.Generators.SyntaxFactsGeneratorFormat command:dotnet format(v8.0.405501+2cb3e68c6b9a966114572fd63f2a20d2cb54a288) Output: https://gist.github.com/GGG-KILLER/81a9773f7c02a12a841edd331751d2eedotnet --info