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

No Maui Project Template and error: Platform version is not present for one or more target frameworks #5778

Closed
ConnorJBrown opened this issue Apr 3, 2022 · 17 comments
Labels
area-setup Installation, setup, requirements, maui-check, workloads, platform support area-templates Project templates, Item Templates for Blazor and MAUI s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@ConnorJBrown
Copy link

ConnorJBrown commented Apr 3, 2022

Description

I seem to have messed up my MAUI installation on Windows VS2022 17.2.0 Preview 2.1.

I cannot see the MAUI template when creating a new project.

When opening an existing MAUI project I see the following error:
Platform version is not present for one or more target frameworks, even though they have specified a platform: net6.0-android, net6.0-ios, net6.0-maccatalyst

Running dotnet workload list gives me the following:

>dotnet workload list

Installed Workload Ids      Installation Source
-----------------------------------------------
maui-windows                VS 17.2.32317.152
maui-maccatalyst            VS 17.2.32317.152
maccatalyst                 VS 17.2.32317.152
maui-ios                    VS 17.2.32317.152
ios                         VS 17.2.32317.152
maui-android                VS 17.2.32317.152
android                     VS 17.2.32317.152

Repairing my VS2022 installation did not fix this, and uninstalling & reinstalling did not fix this either.

Opening the same projects on a different computer with the same VS2022 version works fine

Steps to Reproduce

This issue happens consistently for me but I cannot reproduce it on a different machine.

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

I was not able test on other platforms

Affected platform versions

net6.0-windows10.0.19041;net6.0-android;net6.0-ios;net6.0-maccatalyst

Did you find any workaround?

No response

Relevant log output

No response

@ConnorJBrown ConnorJBrown added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 3, 2022
@jfversluis
Copy link
Member

While it shouldn't be necessary, you can install the templates manually with dotnet new -i Microsoft.Maui.Templates that will also make them show up in VS. Going to trust this fixes it, if not feel free to tag me :) thanks!

@jfversluis jfversluis added area-templates Project templates, Item Templates for Blazor and MAUI area-setup Installation, setup, requirements, maui-check, workloads, platform support and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Apr 4, 2022
@ConnorJBrown
Copy link
Author

ConnorJBrown commented Apr 4, 2022

@jfversluis That fixes the template issue, but I still get the error when opening any MAUI project
Platform version is not present for one or more target frameworks, even though they have specified a platform: net6.0-android, net6.0-ios, net6.0-maccatalyst

When building any MAUI project I get the following errors

Build started...
1>------ Build started: Project: MauiApp1, Configuration: Debug Any CPU ------
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
Failed to restore C:\Users\Connor\source\repos\MauiApp1\MauiApp1\MauiApp1.csproj (in 4 ms).
1>C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: maui-android
1>C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload install maui-android
1>Done building project "MauiApp1.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: maui-ios
1>C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload install maui-ios
1>Done building project "MauiApp1.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: maui-maccatalyst
1>C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload install maui-maccatalyst
1>Done building project "MauiApp1.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: maui-windows
1>C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload install maui-windows
1>Done building project "MauiApp1.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I already have these workloads

>dotnet workload list

Installed Workload Ids      Installation Source
-----------------------------------------------
maui-windows                VS 17.2.32317.152
maui-maccatalyst            VS 17.2.32317.152
maccatalyst                 VS 17.2.32317.152
maui-ios                    VS 17.2.32317.152
ios                         VS 17.2.32317.152
maui-android                VS 17.2.32317.152
android                     VS 17.2.32317.152

Repairing VS2022 preview and uninstalling & reinstalling does not fix the issue like I said in the original post

@jfversluis
Copy link
Member

Interestingly enough just maui is not part of the list. What happens if you manually run dotnet workload install maui?

@ConnorJBrown
Copy link
Author

ConnorJBrown commented Apr 4, 2022

@jfversluis

maui is not part of the list on my other computer where this is not an issue

> dotnet workload install maui

Failed to update the advertising manifest microsoft.net.sdk.macos: microsoft.net.sdk.macos.manifest-6.0.300 is not found in NuGet feeds https://api.nuget.org/v3/index.json"..
Failed to update the advertising manifest microsoft.net.sdk.ios: microsoft.net.sdk.ios.manifest-6.0.300 is not found in NuGet feeds https://api.nuget.org/v3/index.json"..
Failed to update the advertising manifest microsoft.net.sdk.maui: microsoft.net.sdk.maui.manifest-6.0.300 is not found in NuGet feeds https://api.nuget.org/v3/index.json"..
Failed to update the advertising manifest microsoft.net.sdk.tvos: microsoft.net.sdk.tvos.manifest-6.0.300 is not found in NuGet feeds https://api.nuget.org/v3/index.json"..
Failed to update the advertising manifest microsoft.net.sdk.maccatalyst: microsoft.net.sdk.maccatalyst.manifest-6.0.300 is not found in NuGet feeds https://api.nuget.org/v3/index.json"..
Failed to update the advertising manifest microsoft.net.workload.emscripten: microsoft.net.workload.emscripten.manifest-6.0.300 is not found in NuGet feeds https://api.nuget.org/v3/index.json"..
Failed to update the advertising manifest microsoft.net.workload.mono.toolchain: microsoft.net.workload.mono.toolchain.manifest-6.0.300 is not found in NuGet feeds https://api.nuget.org/v3/index.json"..
Failed to update the advertising manifest microsoft.net.sdk.android: microsoft.net.sdk.android.manifest-6.0.300 is not found in NuGet feeds https://api.nuget.org/v3/index.json"..
Downloading microsoft.net.sdk.android.manifest-6.0.300.msi.x64 (33.0.100-preview.4.15)
Workload installation failed. Rolling back installed packs...
Workload installation failed: One or more errors occurred. (microsoft.net.sdk.android.manifest-6.0.300.msi.x64::33.0.100-preview.4.15 is not found in NuGet feeds https://api.nuget.org/v3/index.json".)
Description:
  Install one or more workloads.

Usage:
  dotnet workload install [<WORKLOAD_ID>...] [options]

Arguments:
  <WORKLOAD_ID>  The NuGet package ID of the workload to install.

Options:
  --configfile <FILE>      The NuGet configuration file to use.
  -s, --source <SOURCE>    The NuGet package source to use during the restore. To specify multiple sources, repeat the
                           option.
  --skip-manifest-update   Skip updating the workload manifests.
  --include-previews       Allow prerelease workload manifests.
  --temp-dir <temp-dir>    Specify a temporary directory for this command to download and extract NuGet packages (must
                           be secure).
  --disable-parallel       Prevent restoring multiple projects in parallel.
  --ignore-failed-sources  Treat package source failures as warnings.
  --no-cache               Do not cache packages and http requests.
  --interactive            Allows the command to stop and wait for user input or action (for example to complete
                           authentication).
  -v, --verbosity <LEVEL>  Set the MSBuild verbosity level. Allowed values are q[uiet], m[inimal], n[ormal],
                           d[etailed], and diag[nostic].
  -?, -h, --help           Show command line help.

@jfversluis
Copy link
Member

I'm getting another report for something similar like this so there might be something here. Let's reopen for now.

@jfversluis jfversluis reopened this Apr 5, 2022
@jfversluis
Copy link
Member

As per the instructions here. Would you be able to try and run this?

iwr https://aka.ms/dotnet/maui/maui-install.ps1 -OutFile maui-install.ps1; .\maui-install.ps1 -b 'release/6.0.2xx-preview14' -v '6.0.200-preview'

Of course you're welcome to inspect the contents of the script first if you don't just trust us :)

@ConnorJBrown
Copy link
Author

@jfversluis

Installation rollback failed: One or more errors occurred. (microsoft.netcore.app.runtime.mono.android-arm.msi.x64::6.0.3 is not found in NuGet feeds https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-3ba4b3f4/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-ee0a97a0-1/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-ee0a97a0/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json;https://pkgs.dev.azure.com/xamarin/public/_packaging/SkiaSharp/nuget/v3/index.json".)
Workload installation failed: One or more errors occurred. (microsoft.netcore.app.runtime.mono.android-arm.msi.x64::6.0.3 is not found in NuGet feeds https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-3ba4b3f4/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-ee0a97a0-1/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-ee0a97a0/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json;https://pkgs.dev.azure.com/xamarin/public/_packaging/SkiaSharp/nuget/v3/index.json".)

Here is the full log
MAUI5778Log.txt

@evandigby
Copy link

I am having this same issue. I would attach my logs but they are virtually identical to those of @ConnorJBrown

Please let me know if there's anything I can do to help!

@evandigby
Copy link

After a bit of work and searching, I was able to work around this issue using the following (run from my solution root directory in an admin powershell):

dotnet new globaljson --sdk-version 6.0.200
iwr https://aka.ms/dotnet/maui/maui-install.ps1 -OutFile maui-install.ps1; .\maui-install.ps1 -b 'release/6.0.2xx-preview14' -v '6.0.200'

This assumes you have dotnet SDK 6.0.200 installed. Hopefully it helps you too @ConnorJBrown

@nukedbit
Copy link

nukedbit commented Apr 6, 2022

I'm also expierencing this issue, but it happened after i have uninstalled vs preview an since rienstall i can''t build maui projects anymore.

I also tried your scripts, but it fail with the following errors.

....

Removing Microsoft.Android.Runtime.32.android-x64.31.0.200.109.msi .... Done
Removing Microsoft.Android.Templates.31.0.200.109-x64.msi .... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-arm.Msi.x64 (6.0.3)
Installation rollback failed: One or more errors occurred. (microsoft.netcore.app.runtime.mono.android-arm.msi.x64::6.0.3 is not found in NuGet feeds https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-3ba4b3f4/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-ee0a97a0-1/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-ee0a97a0/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json;https://pkgs.dev.azure.com/xamarin/public/_packaging/SkiaSharp/nuget/v3/index.json".)
Workload installation failed: One or more errors occurred. (microsoft.netcore.app.runtime.mono.android-arm.msi.x64::6.0.3 is not found in NuGet feeds https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-3ba4b3f4/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-ee0a97a0-1/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-ee0a97a0/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json;https://pkgs.dev.azure.com/xamarin/public/_packaCleaning up...

These are the SDK i have installed

5.0.212 [C:\Program Files\dotnet\sdk]
6.0.200 [C:\Program Files\dotnet\sdk]
6.0.300-preview.22154.4 [C:\Program Files\dotnet\sdk]```


@Redth Redth added this to the 6.0.300-servicing milestone Apr 7, 2022
@v-longmin
Copy link

Verified the issue on 17.2.0 Preview 2.1 [32317.152.main], it's not repro.

@v-longmin v-longmin added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Apr 11, 2022
@nukedbit
Copy link

nukedbit commented Apr 12, 2022

Updating to RC1 fixes new projects.

To fix existings project i had to:

  1. i had to reset all visual studio settings.
  2. delete all .vs folders
  3. delete all .user folder

Without deleting those files, Local Packages folder was not listed inside VS, after cleanup maui is working for existing projects i have running locally.

@jfversluis
Copy link
Member

Thanks for being on top of this @nukedbit ! More people seeing this is resolved with the latest release?

@maxkoshevoi
Copy link
Contributor

maxkoshevoi commented Apr 12, 2022

Can confirm that adding global.json with net6 to solution's root fixes it (I also have net7-preview installed, and it seems like it messes maui up)

My global.json:

{
  "sdk": {
    "version": "6.0.300-preview.22204.3"
  }
}

PS: Latest preview didn't fix it, I still need global.json

@ConnorJBrown
Copy link
Author

Installing 6.0.300 RC1 using instructions from here fixes this issue for me

@dylanberry
Copy link

I ran into this as well after installing .NET 7 and can confirm that the fixes offered by @evandigby and @maxkoshevoi work.

cd SolutionRoot
dotnet new globaljson --sdk-version 6.0.300-preview.22204.3

@jfversluis
Copy link
Member

Thanks everyone for letting us know! Seems like not having .NET 7 or adding a global.json does the trick in this case!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-setup Installation, setup, requirements, maui-check, workloads, platform support area-templates Project templates, Item Templates for Blazor and MAUI s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants