dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.6k stars 1.03k forks source link

Cannot change <MauiVersion> in .csproj #38636

Open MeestorX opened 5 months ago

MeestorX commented 5 months ago

Description

I receive the following error if I add <MauiVersion></MauiVersion> to my .csproj:

The type or namespace name 'MauiUIApplicationDelegate' could not be found (are you missing a using directive or an assembly reference?) [{.csproj file name}::TargetFramework=net8.0-maccatalyst]

Steps to Reproduce

Create the default Maui Hybrid app Add the line <MauiVersion>{whatever version of Maui you're currently running or any other version}</MauiVersion> Run for MacCatalyst

In my case, I have 8.0.6 installed and without <MauiVersion> it runs properly. The ONLY value that I can put for <MauiVersion> is 8.0.0-rc.1.9171. Any other value will cause the above error. e.g. <MauiVersion>8.0.0-rc.1.9171</MauiVersion>

This "version string" matches the workload version. I cannot specify any OTHER version of Maui within .csproj to allow me to test a newer build.

Link to public reproduction project repository

No response

Version with bug

8.0.6

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

MacOS Sonoma

Did you find any workaround?

No response

Relevant log output

dotnet list package
Project 'VS2022' has the following package references
   [net8.0-ios16.1]: 
   Top-level Package                                      Requested            Resolved          
   > Microsoft.AspNetCore.Components.WebView.Maui         8.0.6                8.0.6             
   > Microsoft.Extensions.Logging.Debug                   8.0.0-rc.1.23419.4   8.0.0-rc.1.23419.4
   > Microsoft.Maui.Controls                              8.0.6                8.0.6             
   > Microsoft.Maui.Controls.Compatibility                8.0.6                8.0.6             
   > Microsoft.NET.ILLink.Tasks                     (A)   [8.0.1, )            8.0.1             

   [net8.0-maccatalyst16.1]: 
   Top-level Package                                      Requested            Resolved          
   > Microsoft.AspNetCore.Components.WebView.Maui         8.0.6                8.0.6             
   > Microsoft.Extensions.Logging.Debug                   8.0.0-rc.1.23419.4   8.0.0-rc.1.23419.4
   > Microsoft.Maui.Controls                              8.0.6                8.0.6             
   > Microsoft.Maui.Controls.Compatibility                8.0.6                8.0.6             
   > Microsoft.NET.ILLink.Tasks                     (A)   [8.0.1, )            8.0.1             

(A) : Auto-referenced package.

dotnet workload list
Installed Workload Id      Manifest Version                     Installation Source
-----------------------------------------------------------------------------------
maui-maccatalyst           8.0.0-rc.1.9171/8.0.100-rc.1         SDK 8.0.100        
ios                        16.4.8825-net8-rc1/8.0.100-rc.1      SDK 8.0.100        
maui                       8.0.0-rc.1.9171/8.0.100-rc.1         SDK 8.0.100        

Use `dotnet workload search` to find additional workloads to install.
MeestorX commented 5 months ago

Is this the same issue? https://github.com/dotnet/maui/issues/20099

drasticactions commented 5 months ago

Are you referencing the Nuget packages in your project?

    <ItemGroup>
        <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
        <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
    </ItemGroup>

If you don't reference the nugets, changing MauiVersion will, I believe, change the Workload version. That's why it fails for you, since you only have that version installed. Also, you should really update to .NET SDK 8.0.1 and the newest Workloads (dotnet workload update), those are .NET 8.0 RC1 builds and are quite old.

ghost commented 5 months ago

Hi @MeestorX. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 5 months ago

Hi @MeestorX. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

MeestorX commented 5 months ago

Are you referencing the Nuget packages in your project?

Yes, those lines are still in there. As I said, I just created the dotnet maui-blazor template (dotnet new maui-blazer) and only added the <MauiVersion> line to .csproj.

Also, you should really update to .NET SDK 8.0.1 and the newest Workloads (dotnet workload update), those are .NET 8.0 RC1 builds and are quite old.

I have run sudo dotnet workload update a few times. It doesn't make any changes. The version looks to be 8.0.100 in the workloads, but you can see I've got 8.0.6 for MauiControls.

MeestorX commented 5 months ago

So this is an SDK issue, not Maui? I noticed you moved it from Maui.

MeestorX commented 5 months ago

Looks like the problem became widespread! https://github.com/dotnet/maui/issues/20600