novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
347 stars 42 forks source link

VS16.2: Xaml Compiler Error when including Microsoft.Xaml.Behaviors.Uwp.Managed #182

Closed jeromelaban closed 5 years ago

jeromelaban commented 5 years ago

When building the project below with VS 16.2 and higher, with MSBuild extras 2.0.0-preview.7 and higher, the following error appears:

XamlCompiler error WMC1006: Cannot resolve Assembly or Windows Metadata file 
'Type universe cannot resolve assembly: Windows.Foundation.UniversalApiContract,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime.'

When using MSBuild extras 1.6.68, the project builds successfully.

The project:

<Project Sdk="MSBuild.Sdk.Extras/2.0.0-preview.7">

  <PropertyGroup>
    <TargetFrameworks>uap10.0.16299</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.0.1" />
  </ItemGroup>
</Project>

Installing the SDK 10586 (where the 2.0.0.0 was introduced) does not fix the issue. TestXamlCrash.zip

jeromelaban commented 5 years ago

This issue impacts the windows community toolkit. I'm trying to chase down where the origin of the issue, without much luck yet.

jeromelaban commented 5 years ago

Ok, I was lucky this time. It seems that:

https://github.com/onovotny/MSBuildSdkExtras/blob/f1476ba441d9eacf4152ea04e5cc2e05b97ea6f8/Source/MSBuild.Sdk.Extras/Build/Platforms/Windows.targets#L63

is to blame. Setting it to true fixes the issue.

@onovotny Would you know what is the use of the property ?

jeromelaban commented 5 years ago

Thanks Oren!