-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Visual Studio 17.2.6 Breaks CommunityToolkit.Mvvm #6792
Comments
If you build your project from the developer command prompt and pass
|
Wow, first I've seen of this tool. There's an insane amount of info, but I can't seem to find that needle in this haystack. Here's the output from building my tiny test project in case you have a better idea of where in there to look. |
It's in the Csc task which contains the build errors, under CommandLineArguments In this case the paths appear to be:
In other words, the two paths are exactly the same. It's odd that msbuild would do that, It feels like the compiler should be modified to give a diagnostic and/or dedupe the duplicate generators. I'll have to look more closely later to confirm that and determine a root cause. |
Got similar problem after updating from 6.0.6 to 6.0.7 (sdk 6.0.301 to 6.0.302) but with code ganareted via CsWin32 Minimal repro crated by WPF apllication template from Visual studio 2022 and adding mentioned nuget: Moving code generation to separate class library fixes issue. dotnet --info
C:\WpfApp.Issue62582>dotnet --info Runtime Environment: global.json file: Host: .NET SDKs installed: .NET runtimes installed: Download .NET: Learn about .NET Runtimes and SDKs: dotnet buildC:\WpfApp.Issue62582>dotnet build Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET Copyright (C) Microsoft Corporation. All rights reserved. Determining projects to restore... Build FAILED. C:\WpfApp.Issue62582\Microsoft.Windows.CsWin32\Microsoft.Windows.CsWin32.SourceGenerator\Windows.Win32.WINDOW_STYLE.g.cs(23,15): error CS0101: The namespace 'Windows.Win32.UI.WindowsAndMe Time Elapsed 00:00:02.94 |
This is a generic problem that affects all source generator projects. <ProjectReference Include="..\Xxx.Generator\Xxx.Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> |
I also have faced the same problem with Refit. |
I uninstalled VS 17.2.6 and installed 17.2.5 that used to work. It doesn't anymore :-( Still the same error. |
@tan-force seems to be related to dotnet 6.0.7 so you may have to uninstall that version |
Yes! Uninstalled dotnet 6.0.7, and now it works. Thank you. |
You still can use the latest version of Visual Studio. Here is a workaround that works for me:
{
"sdk": {
"version": "6.0.301",
"rollForward": "disable"
}
}
|
Source generators still working in actual VS2022 preview. |
I've the same problem in latest preview (17.3.0 Preview 3.0) |
We have the same problem with a WPF (class library) project that uses Refit:
Something seems to be broken in the GenerateTemporaryTargetAssembly build task. |
I don't believe this is the right repo for this issue. @rainersigwald do you know where this may need to go? |
Cannot Install .NET SDK (6.0.301) as it is showing error - Another version of this product is already installed |
I apologize for the regression. It was caused by my changes in #6534 which were backported to .Net 6 in #6680. I posted workaround for this issue here: #6680 (comment). This is an alternative to this workaround: #6792. I'm working on a fix that can hopefully be included in .Net 6.0.8. |
@saivineeth100 , |
Is the fix for this available in the .NET 7 preview SDK at this point? edit: ah, just saw this:
|
Still occurred in latest .NET 7 Preview |
Thanks @rainersigwald for this solution. It looks like it fixed the issue with the duplicate analyzers 🙂👍 Unfortunately it also looks like it may have an unattended side effect 🤔 public partial class App : System.Windows.Application
{
public App(SplashScreen splash)
{
// (removed for readability)
}
} MSBuild then generates a partial class with // <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// (...)
public partial class App : System.Windows.Application
{
// (removed for readability)
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "6.0.8.0")]
public static void Main() {
LocusMobile.Client.App app = new LocusMobile.Client.App();
app.InitializeComponent();
app.Run();
}
} Resulting in: error CS7036: There is no argument given that corresponds to the required formal parameter 'splash' of 'App.App(SplashScreen)' Anyone other that has experienced this with the workaround? Or also has a constructor with a parameter that is not affected by this workaround, and can confirm that this issue must come from something else? I experienced this issue with the generators when switching from legacy project file to SDK style project file, so my error might be related to something else as well... |
Hey @Gakk, I doubt that your issue is related to analyzers/generators. This is likely the cause: Without a repro I can only speculate but it looks like you use your own Main entry point instead of the generated App.Main and pass a SplashScreen to the constructor of App. In your legacy project file, App.xaml was probably included as Thanks. |
This issue should now be fixed in .Net SDK 6.0.9 released today. |
I had the same problem today! How to fix it? `Version: 6.0.401 Runtime Environment: global.json file: Host: .NET SDKs installed: .NET runtimes installed: |
@ecxdev If you have .NET 7 preview-7 upgrade to .NET 7 RC-1 and it should fix it. Either that or specify version 6 in global.json |
The project was rebuilt successfully when I deleted this previously inserted code from the project file. |
This reverts commit 8466ca1.
Related to .NET Core + CommunityToolkit.Mvvm (dotnet/wpf#6792) .NET SDK should be updated to 6.0.9 (6.0.4 .NET Core version)
Version Used: 17.2.6
Steps to Reproduce:
net6.0-windows
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
ObservableObject
, like so:Expected Behavior:
In 17.2.5, it built and ran fine.
Actual Behavior:
It appears that somehow the CommunityToolkit.Mvvm source generators are being run twice.
If you create a WPF class library, things work fine. They're only broken in a WPF app.
Here is my test project:
ObservablePropertyTest.zip
The text was updated successfully, but these errors were encountered: