Add dummy assembly to the UWP NuGet package, to workaround .NET Native compiler bug

If an app does not directly reference any numerics types, the current compiler incorrectly drops
its reference to System.Numerics.Vectors.dll, which breaks the build. Workaround is to always
include a stub assembly that explicitly uses one of the numeric types.
This commit is contained in:
Shawn Hargreaves 2015-07-23 16:29:13 -07:00
Родитель 3c9b56109c
Коммит 3ac6a77f35
10 изменённых файлов: 126 добавлений и 5 удалений

Просмотреть файл

@ -87,6 +87,7 @@
<ItemGroup Condition="$(BuildUAP)">
<UAPProject Include="winrt\lib\winrt.lib.uap.vcxproj" />
<UAPProject Include="winrt\dll\winrt.dll.uap.vcxproj" />
<AnyCPUProject Include="numerics\Workaround1200257\Workaround1200257.csproj" />
</ItemGroup>
<!-- Windows test projects -->

Просмотреть файл

@ -92,6 +92,10 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ExampleGallery.BackgroundTa
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExampleGallery.BackgroundTask", "ExampleGallery.BackgroundTask", "{BB7C16DA-A97B-4C62-86A2-05739B418676}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "numerics", "numerics", "{D6BC00F7-D194-4136-8382-55B222A5C6F1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Workaround1200257", "numerics\Workaround1200257\Workaround1200257.csproj", "{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
winrt\test.managed\Shared\winrt.test.managed.Shared.projitems*{70fb7b71-d56c-4bf1-9282-27aa58043cc0}*SharedItemsImports = 4
@ -277,6 +281,18 @@ Global
{D77EB5BE-C840-4ADE-B4F6-1BA9512C4768}.Release|Win32.Build.0 = Release|x86
{D77EB5BE-C840-4ADE-B4F6-1BA9512C4768}.Release|x64.ActiveCfg = Release|x64
{D77EB5BE-C840-4ADE-B4F6-1BA9512C4768}.Release|x64.Build.0 = Release|x64
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Debug|ARM.ActiveCfg = Debug|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Debug|ARM.Build.0 = Debug|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Debug|Win32.ActiveCfg = Debug|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Debug|Win32.Build.0 = Debug|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Debug|x64.ActiveCfg = Debug|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Debug|x64.Build.0 = Debug|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Release|ARM.ActiveCfg = Release|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Release|ARM.Build.0 = Release|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Release|Win32.ActiveCfg = Release|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Release|Win32.Build.0 = Release|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Release|x64.ActiveCfg = Release|Any CPU
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -313,5 +329,6 @@ Global
{D77EB5BE-C840-4ADE-B4F6-1BA9512C4768} = {BB7C16DA-A97B-4C62-86A2-05739B418676}
{75A7926B-B1AE-4806-B332-9561BFE0EDF9} = {BB7C16DA-A97B-4C62-86A2-05739B418676}
{BB7C16DA-A97B-4C62-86A2-05739B418676} = {671EACB0-6255-4050-B092-1A874625AD5C}
{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA} = {D6BC00F7-D194-4136-8382-55B222A5C6F1}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -27,6 +27,9 @@
<file target="lib\uap10.0\Microsoft.Graphics.Canvas.winmd" src="$bin$\UAPx86\release\winrt.dll.UAP\Microsoft.Graphics.Canvas.winmd" />
<file target="lib\uap10.0\Microsoft.Graphics.Canvas.xml" src="bin\intellisense\Microsoft.Graphics.Canvas.xml" />
<file target="lib\uap10.0\en\Microsoft.Graphics.Canvas.xml" src="bin\intellisense\Microsoft.Graphics.Canvas.xml" /> <!-- [1] -->
<file target="lib\uap10.0\Workaround1200257.dll" src="$bin$\UAPAnyCPU\release\Workaround1200257\Workaround1200257.dll" />
<file target="lib\win\Microsoft.Graphics.Canvas.winmd" src="$bin$\UAPx86\release\winrt.dll.UAP\Microsoft.Graphics.Canvas.winmd" />
<file target="lib\win\Microsoft.Graphics.Canvas.xml" src="bin\intellisense\Microsoft.Graphics.Canvas.xml" />
<file target="lib\win\en\Microsoft.Graphics.Canvas.xml" src="bin\intellisense\Microsoft.Graphics.Canvas.xml" /> <!-- [1] -->

Просмотреть файл

@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
namespace Workaround1200257
{
// Force a reference to the System.Numerics.Vectors assembly, to workaround a .NET Native
// compiler bug where release builds using Win2D fail if the app does not itself directly
// use any of the numerics types.
//
// TODO: remove this workaround when DevDiv:1200257 is fixed.
class ForceNumericsReference
{
public ForceNumericsReference()
{
var a = System.Numerics.Vector2.Zero;
var b = a.X;
}
}
}

Просмотреть файл

@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
using System.Reflection;
[assembly: AssemblyTitle("Workaround1200257")]
[assembly: AssemblyProduct("Win2D")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")]

Просмотреть файл

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4EDD6AD1-0BD4-40CF-8D02-53597B1A76BA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Workaround1200257</RootNamespace>
<AssemblyName>Workaround1200257</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<Import Project="..\..\build\Win2D.cs.props" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="ForceNumericsReference.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,16 @@
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}

Просмотреть файл

@ -24,10 +24,6 @@ namespace SimpleSample
{
this.InitializeComponent();
this.Suspending += OnSuspending;
// TODO: remove this workaround once we have a project we can reference that does it for us
var a = System.Numerics.Vector2.Zero;
var b = a.X;
}
/// <summary>

Просмотреть файл

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@ -119,6 +119,10 @@
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\numerics\Workaround1200257\Workaround1200257.csproj">
<Project>{4edd6ad1-0bd4-40cf-8d02-53597b1a76ba}</Project>
<Name>Workaround1200257</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\winrt\dll\winrt.dll.uap.vcxproj">
<Project>{8cf21e5d-e0a2-4fe7-8e2b-a025cf52dcfb}</Project>
<Name>winrt.dll.uap</Name>

Просмотреть файл

@ -43,5 +43,6 @@ Licensed under the MIT License. See LICENSE.txt in the project root for license
<Win2DProject Name="winrt.dll.uap.vcxproj" />
<Win2DProject Name="DotNetNumerics.Windows.csproj" />
<Win2DProject Name="DotNetNumerics.WindowsPhone.csproj" />
<Win2DProject Name="Workaround1200257.csproj" />
</ExportSamples>