Microsoft-ui-xaml: Error while creating a WinUI 3, C# on Desktop project.

Created on 18 Jul 2020  路  18Comments  路  Source: microsoft/microsoft-ui-xaml

Describe the bug
Creating a new WinUI 3,0 project using the C# on Desktop (package) project results in an error:

A problem was encountered creating the sub project 'Arctium Sandbox Studio'. 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

Steps to reproduce the bug

  1. Install the latest VS 2019 Preview+ .NET 5 (Preview 8/RC1)
  2. Install the WinUI 3.0 Preview2 extension.
  3. Create a WinUI C# on Desktop project.

Expected behavior
It should create the project without any errors instead of failing.

Version Info
WinUI 3 Preview 2


Windows 10 Pro Insider Preview Build 20170


Desktop

Additional context

Area-Desktop area-NugetPackage winui3preview

Most helpful comment

Here is the install script I use Install-DotNet.zip

If you run this in an admin powershell window: Install-DotNet -version 5.0.100-preview.5.20279.10. This will install both x86 and x64 to program files.

Then you can add a global.json that looks like this:

{
  "sdk": {
    "version": "5.0.100-preview.5.20279.10"
  }
}

All 18 comments

@Fabi have you installed both the x86 and x64 versions of the .net 5 sdk?

@alwu-msft and @stevenbrix FYI.

Occurs to me, I have nightlies of x86 and 64 SDK installed

Fixes if you regress to preview 5 @Fabi

Yes, sorry. Works with Preview 5.

@alwu-msft or @stevenbrix is this a known requirement?

We've only tested with .NET 5 Preview 5 so far. It is not surprising that subsequent .NET 5 Previews might cause issues as there is no guarantee of compatibility between different previews.

Just as an update, with VS 16.8.0 Preview 2, and .Net5 Preview 8 (x86 and x64 sdks installed), I am observing the same behavior on new project creation.

Sorry for not responding to this earlier - yeah we have incompatibilities with preview8 of net5 and 16.8 Preview2.

The only current recommendation I can give is to stay on VS16.7.2 and .NET5 Preview5 (not great, I know). If you want to keep preview8 installed, I'd recommend installing .net5 preview5 using the dotnet install scripts and use global.json to make sure it's picked up.

Here is the install script I use Install-DotNet.zip

If you run this in an admin powershell window: Install-DotNet -version 5.0.100-preview.5.20279.10. This will install both x86 and x64 to program files.

Then you can add a global.json that looks like this:

{
  "sdk": {
    "version": "5.0.100-preview.5.20279.10"
  }
}

@stevenbrix no problem! Thanks for the update and workaround.

I got the same error, pls helps....

@akunzz you can either uninstall preview8 and install preview5 of .net5, or keep preview8 installed and use the install scripts and global.json workaround I described above.

Either way, you need to use VS16.7.2.

A couple of extra comment for anyone trying to get this:

  • Run the Install-Dotnet script from an elevated prompt
  • If you're creating a new solution, create an empty solution, put the global.json file in the same folder as the .sln file and then you can add the WinUI for desktop project to the solution. If you don't do this, you'll see the error listed in the issue above, even if you've run the install script

Now getting the following error when attempting to build and run - any help would be appreciated:

error NETSDK1005: Assets file 'c:\temp\App5\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.

Ignore this I didn't read the instructions above fully and missed the point that says "Either way, you need to use VS16.7.2". I was trying to run on 16.8 preview 2 and that doesn't work. Running on 16.7 seems to.

Is this issue expected to be fixed when using VS 16.8.0 Preview 5.0+ and .NET 5.0.100-rc.2?

Attempting to create Blank App, Packaged (WinUI in Desktop) ...

The same here, VS 16.8 Preview 5.0 and .NET 5 rc2
image

This will be fixed in WinUI 3 Preview 3. Unfortunately .NET 5 has had a lot of breaking changes since we released Preview 2; you will need to stick with VS 16.7 and .NET 5 Preview 5 (although I've seen some reports that .NET 5 Preview 7 is the most recent version that is still compatible).

With .NET 5 just around the corner, when do you think this will be fixed?

Was this page helpful?
0 / 5 - 0 ratings