Why can't I compile a .NET MAUI app on Visual Studio 2022? - visual-studio-2022

I wanted to start coding something using .NET MAUI, so I updated my VS2022 to "Version 17.1.0 Preview 6.0".
Then I installed these features using "Visual Studio Installer" as suggested in https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation
Unfortunately when I create a basic MAUI app, I get several errors like this:
Error NU1012 Platform version is not present for one or more target
frameworks, even though they have specified a platform: net6.0-android
On developer command line I tried running dotnet workload list and got
android
ios
maui-android
maui-maccatalyst
If I try to install some other workload (eg maui or maui-windows) I get an error stating
Unable to download manifest microsoft.net.workload.emscripten:
microsoft.net.workload.emscripten.manifest-6.0.200 has not been found
on NuGet feeds https://api.nuget.org/v3/index.json, C:\Program Files
(x86)\Microsoft SDKs\NuGetPackages"
I've also tried to completely remove and reinstall VS2022, without any luck.
I've then tried to run maui-check but when it tries to download Recommendation: Download .NET SDK (6.0.200) the exe is not valid and the task fails.
Worst part: I tried to install a fresh VS2022 preview on a different pc and everything works flawlessly... but I need it to work on my developmente pc!
.

Related

How to publish Windows only MAUI app in Visual Studio 2022 17.4 onwards?

Context:
I have a MAUI app I have been working on which, for now, only has Windows listed as a TargetFramework in the project file. Until VS2022 17.4 arrived I was able to build and publish this using a publish profile (pubxml) file.
The problem:
Now that 17.4 has dropped, trying to publish the application fails because it no longer uses the pubxml file unless you have more than one platform specified in the TargetFrameworks. I can still publish the app via the command line using -r win10-x64 instead of -a x64 but am completely unable to publish without at least adding android as a TF.
Has anyone else seen this and found a better workaround?
STR:
Create a new MAUI app, enter the project file and remove the line specifying the non-Windows TFs, try to publish using gui.

How can I install a newer MSBuild version?

I am trying to build Microsoft.AspnetCore.Identity from sources. The instructions are here: https://github.com/dotnet/aspnetcore/blob/master/docs/BuildFromSource.md. I am trying to run their command "restore.cmd" and hitting the following error:
error : Version 3.1.10 2 of the .NET Core SDK requires at least version 16.3.0 of MSBuild. The current available version of MSBuild is 16.0.46
1.62831. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.
The error message's suggestion of changing the .Net Core SDK version seems absurd. Surely the solution is to install MSBuild 16.3.0. But how do I do that?
As an aside which may or may not be relevant, the instructions also have a script for installing the "exact required" version of VS. But it seems to install a new one that goes side-by-side with my existing version. Their "startvs" command then starts the existing one, rather than the new one. It has to be better to add everything needed to the existing installation. But I'm missing how to add MSBuild 16.3.0.
The error message's suggestion of changing the .Net Core SDK version
seems absurd. Surely the solution is to install MSBuild 16.3.0. But
how do I do that?
1) Please make sure that you have run ./eng/scripts/InstallVisualStudio.ps1 to install the required tools.
2) If you have VS2019, try to enable the option Use previews of the .NET Core SDK(require restart) under Tools--> Options-->Environment-->Preview Features.
a) If you have VS2019 at your agent, just update it to the latest version so that you will get the latest version about MSBuild.
b) Download the latest version of Build Tool for VS2019. You can download it under Tools for Visual Studio 2019 from this link. If you have already downloaded it, please update it to the latest version in vs installer. Also, make sure that you have install the workload Net Core build tools. After that, you can build net core projects with it.
3) Then try to run .\restore.cmd in developer command prompt.

"Error 0x80070005: Failed to launch clean room process" while installing .Net Core SDK 2.1

My Visual Studio 2017 Professional stopped being able to load some projects in a solution, and on investigation, VS tells me that I have to install the ASP.NET and Web development feature. I'm sure that this is already installed (I have built this solution many times), but oh, well, I decided to click Install and re-install what VS claimed to be missing.
The VS 2017 Installer window displays and starts attempting to install .Net Core SDK 2.1. For some reason this silently fails. So I downloaded the executable dotnet-sdk-2.1.101-win-x64.exe and try to Run this as Administrator. This appears to start and then stops. Checking its log (C:\Users\Administrator.DOMAIN\AppData\Local\Temp\2\Setup_20180322072534_Failed.txt), I can see the following error:
[1330:15A4][2018-03-22T07:25:34]e000: Error 0x80070005: Failed to launch clean room process: "C:\Windows\Temp{6B5E7797-D824-4BF0-9B51-A0375BFCE6F3}.cr\dotnet-sdk-2.1.102-win-x64.exe" -burn.clean.room="C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Net.Core.SDK,version=15.6.27428.2011,chip=x64\dotnet-sdk-2.1.102-win-x64.exe" -burn.filehandle.attached=212 -burn.filehandle.self=220 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional" /log "C:\Users\Administrator.DODSON\AppData\Local\Temp\2\dd_setup_20180322072448_001_Microsoft.Net.Core.SDK.log" /quiet /norestart
I googled around for this error, and tried a couple of suggestions:
Changed the permissions on the C:\Windows\Temp so that Everyone has full control
Repaired the VC 2017 Redistributables
Updated Permissions on some registry keys relating to VC 2017 Minimum (I forget the exact name of the keys)
Nothing has worked, and I seem to be stuck. I don't seem to be able to install the ASP.NET and Web development feature without the .Net Core SD. Has anyone seen or solved this problem?
In case anyone runs into the same issue, I will post my solution. Essentially, I reset the permissions on the C:\Windows\Temp directory to allow Everyone full control permissions, and then manually re-ran the dotnet-sdk-2.1.101-win-x64.exe installer again as Administrator. This time it succeeded in installing the .Net Core SDK. I then ran the Visual Studio Installer again to re-install the ASP.NET and Web development feature, and now everything is working again.

VS2017 : Target framework drop down does not show .NET Core 2.1 option

I have already installed VS2017 Enterprise 15.6.4. Recently installed .NET Core 2.1.101 SDK from official site
I was expecting .NET Core 2.1 as one of the target framework available if I create console or asp.net core application. Can someone help me understanding what I am missing here.
As suggested in comments, I installed 15.7 preview 2. Still no luck and same issue.
I have faced the same problem. I solved this by installing the right SDKs with Runtime for .NET Core 2.1.
Basically to run/create 2.1 projects from VS Preview, you need to install the "2.1.300" (not 2.1.4) .NET Core SDKs and Runtime. https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-preview1 (this includes required Runtime already)
The good explanation of this misleading with versions i found here https://github.com/dotnet/cli/issues/8309 (dasMulli commented on Feb 24).
In case this helps someone else... After installing VS 15.9.2 my project that was working fine with 2.2 preview-3 stopped working. VS could not see the preview SDK. I could build the solution using dotnet.exe but not VS.
To solve this I created a global.json at the root folder of this solution pointing to the preview sdk. That allowed VS to see the preview version.
This is a change of behavior in VS between 15.8.x and 15.9.x.
To create the global.json you can navigate to the desired folder and type this:
dotnet new globaljson
Make sure dotnet PATH variables are in correct order
If you have installed an SDK for a different system architecture (e.g., if you installed 32-bit/x86 SDK on a 64-bit computer), then a new entry in the PATH variable would have been created for that specific location (e.g., C:\Program Files\dotnet or C:\Program Files (x86)\dotnet).
The problem is that Visual Studio, when searching for installed frameworks, will stop at the first PATH variable entry it finds that contains an SDK. So, if the first version you installed used an incorrect architecture, then you'll have to adjust the position of those entries before any of the correct SDKs will appear in the Target Framework drop down.
Source: this absurdly-hard-to-find comment within issue #8309.
TL;DR: Make sure the first "C:\Program Files\dotnet\" entry in your path variable you see in the list matches your system architecture:
64-bit = C:\Program Files\dotnet\
32-bit = C:\Program Files (x86)\dotnet\
Make sure that Visual Studio 2017 is up to date. Go to "Tools" -> "Extensions and Updates" to install visual studio updates. This resolved the issue for me.
I have faced the similar situation I tried to install the preview version of the dot net but it did not help.
However after I updated visual studio (from 15.8 to 15.9.6 ).
I Could see dot net core 2.1 in the target framework.
Updated to Latest VS 2017 and installed latest .Net Core SDK.
Changed global.json to point to latest version installed.
This resolved for me.
I had faced the similar issue. I then just updated my Visual Studio 2017 to 15.9.16 version and restarted the system. The problem got resolved.
I was facing the similar issue, I uninstalled the .Net Core 2.2 runtime and then from the below link:
https://dotnet.microsoft.com/download/visual-studio-sdks?utm_source=getdotnetsdk&utm_medium=referral
Install the .Net Core 2.2 Visual Studio SDK, Restarted the Visual Studio and my issue got resolved, .Net Core 2.2 is now getting listed in Target Framework list in the project properties in Visual Studio 2017 Version 15.9.16
I created a new project under .net core 2.1 and it was ok but in my old project have not appeared. So I opened both ".cproject" files and compared them together and found the problem.
Open your project's ".cproject" file in a text editor then replace below line
<TargetFramework>netstandard2.1</TargetFramework>
with this one:
<TargetFramework>netcoreapp2.1</TargetFramework>

Creating New Wix Project In Visual Studio 2017 throws an error

I have installed Visual Studio 2017 Community Edition. Installed it without any specific things selected like C++ development or Windows development etc. After that I have installed Wix through wixtoolset, which downloaded and installed wix tool set components. After that I have installed the Wix ToolSet extension for Visual Studio 2017. Restarted the Visual Studio and trying to create a new project through File -> New -> Project - WiX Toolset -> Setup Project.
It gives the error and does not let me create the project. I am totally new to WiX and have just a little knowledge about Visual Studio.
Initially, I did not select any of the Installation workloads for VS17 and installed it just to make the installation faster.
Through the comments from Azaz, I came to know that NuGet Package Manager is required to install the packages on demand. But since I could not see the NuGet option at all, I tried to install it with Extensions and updates but it did not work. I did a bit of research and found that at least one .Net development workload is required at a time of VS17 installation which will make the NuGet install automatically in VS17.
So I uninstalled the VS17, WiX at all and removed them from the system. Then Installed VS17 with certain workload packages as shown in the below screenshot.
After that I installed WiX and an extension for the same in VS17. i.e. Votive2017.vsix.
I restart the VS17 and now I am able to create project for WiX.
Looks like there is something I missed somewhere in installing which did not let me install required DLLs and GUID feature, which were important for creating project templates.
Sharing the steps I followed in order to fix the same issue that I found with Visual Studio 2019, as I also installed it without any workload. I was also looking at a reduced installation.
The steps I did in order to fix the template error, install the following individual components:
.NET 5.0 Runtime
.Net Core 3.1 Runtime
.NET SDK
C# and Visual Baisc Roslyn compilers
ClickOnce Publishing
Microsoft Visual Studio Installer Projects
Hope it helps someone else. I have to point out that the comments before helped me understand the issue. But, for example, I couldn't even open the NuGet command line.