If you’ve recently upgraded to the latest Visual Studio preview (Preview 2 of VS 16.8) then you may run into issues if you attempt to create a new WinUI for Desktop project. You’ll see a prompt similar to the following and only the packaging project will get created.
The full text from the error is as follows.
Microsoft Visual Studio
A problem was encountered creating the sub project 'MasterDetail.Desktop'. The expression "[Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformSDKLocation('', 10.0.18362.0)" cannot be evaluated. Parameter "targetPlatformIdentifier" cannot have zero length. C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets
The solution to this issue has been covered over at this github issue. The main steps are:
Open an elevated command or powershell terminal window and run Install-DotNet -version 5.0.100-preview.5.20279.10
Open Visual Studio and create an empty solution
Note: If you attempt to simply create a new solution using the Blank App template, you’ll see the same error as before. You need to have the global.json file in the root folder before the WinUI project is created.
Add global.json file with the following content to the root folder of the solution (the same folder as the .sln file):
Add project using the “Blank App, Packaged (WinUI in Desktop)” template
At this point you’ll be thinking to yourself that everything is looking good and you’ve successfully created your WinUI project. Unfortunately, when you go to run your project you’ll see an error similar to.
Severity Code Description Project File Line Suppression State
Error NETSDK1005 Assets file 'c:\temp\App1\App1\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v5.0'. Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project. App1 C:\Program Files\dotnet\sdk\5.0.100-preview.5.20279.10\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234
If you read the GitHub issue, you’ll note that it very clearly says “you need to use VS16.7.2”.
Make sure you are using Visual Studio 16.7, not Visual Studio 16.8 preview 2. The point of this post is that if you have both installed side by side, the installation of preview 2 will break your ability to run WinUI for Desktop projects. Adding the global.json file to your solution folder will fix this issue.
Building and deploying UWP apps on Xbox is frustrating – every time I come back to it I get caught out by things that should just work. The one that always seems to get me is that you have to be signed in on the Xbox. This used to not be a problem because Visual Studio used to recognise this issue and provide you a nice reminder – I think it was in the Output window but can’t be sure for certain.
I just attempted to debug an app on the Xbox from the latest version of Visual Studio (both preview and stable) and got the following completely unhelpful error message:
Unable to activate Windows Store app 'XXX.YYYYYYYY_ZZZZZZZZApp'. The activation request failed with error 'Operation not supported. Unknown error: 0x8004090a'.
After rebuilding, cleaning the solution, restarting the Xbox and a variety of other things, I remembered to check that a user was signed in on the Xbox. Sure enough it wasn’t and sure enough, signing in, fixed the activation error.
If you come across this error, make sure you’re signed into an account on the Xbox!!!
Over the last 24hrs I’ve had to setup a new dev machine from scratch. After installing all the bits and pieces I need to test out to make sure I can build and deploy apps to Android, iOS and Windows. After creating a new Xamarin.Forms application I set the UWP head project to be the startup project and hit run….. and waited….. and waited….. and waited.
I’m sure that there are going to be readers out there that will answer this by saying – download nuget and run a manual restore; or call dotnet restore from the package manager. But seriously??? why am I having to do this??? Why it Visual Studio so broken that I can just run the UWP head project of a new Xamarin.Forms application.
I went into manage nuget packages and upgraded the Microsoft.NETCore.UniversalWindowsPlatform package.
After a 20minute wait, it eventually upgraded the package. There after I was able to build and run my UWP application.
Ironically I complained about this back in August last year (the previous time I had to setup a replacement device).
New PC, Clean install of VS2019 (inc UWP components), Create new Uno project, Attempt to run UWP project……10minutes later VS is still attempting to download bits. Seriously this is the worst dev experience. @VisualStudio