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
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
@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:
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
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?
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: