WindowsAppSDK: The function "Is64BitProcess" on type "System.Environment" is not available
Describe the bug
When building a C# project that references Microsoft.WindowsAppSDK
using dotnet build
, the following error happens:
.nuget\packages\microsoft.windows.sdk.buildtools\10.0.20348.19\build\Microsoft.Windows.SDK.BuildTools.props(4,37): error MSB4185: The function "Is64BitProcess" on type "System.Environment" is not available for execution as an MSBuild property function.
Steps to reproduce the bug
Create a csproj with the following content:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK">
<Version>1.0.0-preview2</Version>
</PackageReference>
</ItemGroup>
</Project>
Then run dotnet build
in the folder containing the project.
Expected behavior The build passes.
Version Info
VS 2022 Preview 6
dotnet 6.0.100-rc.2.21505.57
, but also happens on earlier versions
NuGet package version: Microsoft.WindowsAppSDK 1.0.0-preview2
Windows version | Saw the problem? |
---|---|
Insider Build (xxxxx) | |
May 2020 Update (19041) | |
November 2019 Update (18363) | |
May 2019 Update (18362) | |
October 2018 Update (17763) |
Additional context
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 19 (6 by maintainers)
Commits related to this issue
- use msbuild instead of dotnet cli workaround for microsoft/WindowsAppSDK#1652 — committed to tibel/Caliburn.Light by tibel 3 years ago
- Workaround for dotnet build https://github.com/microsoft/WindowsAppSDK/issues/1652 — committed to SlashNephy/NiceHashQuickMiner.RichPresence by SlashNephy 3 years ago
- update analysis - remove csharp remove csharp from auto builds because WinUI projects cannot be compiled with `dotnet build` https://github.com/microsoft/WindowsAppSDK/issues/1652 — committed to ProfessionalCSharp/ProfessionalCSharp2021 by christiannagel 2 years ago
FYI that this issue will be fixed in .NET 6.0.300 per https://github.com/dotnet/msbuild/issues/7329.
This also occurs on Preview 3 and with version
10.0.22489-preview
ofMicrosoft.Windows.Sdk.BuildTools
.nuget\packages\microsoft.windows.sdk.buildtools\10.0.22489-preview\build\Microsoft.Windows.SDK.BuildTools.props(4,37): error MSB4185: The function "Is64BitProcess" on type "System.Environment" is not available for execution as an MSBuild property function.
Internal bug on BuildTools is http://task.ms/37199033.
Windows App SDK, independent of the Windows SDK Build Tools Nuget package, does not support
dotnet build
at this time.This is probably not an msbuild issue, but rather the fact that the WinAppSDK (and the WinUI 3 XAML compiler, if you manually fix this issue) rely on the behavior of the .NET framework 4.x.
@jeromelaban - It looks like these are the culprits that define whether
Is64BitProcess
is available to use or not. From the code, it makes sense why it only builds when callingmsbuild
from the VS Developer Command linehttps://github.com/dotnet/msbuild/blob/ad0ea36eb0e5670454c8cc7a3942717d4db9dab1/src/Build/Resources/Constants.cs#L306
https://github.com/dotnet/msbuild/blob/a7d579050450d7ee8c156cd652af18ee42b3570c/src/Directory.BeforeCommon.targets#L19-L20