Inject Module Constructor into PCore (#741)

PresentationCore used to have a module constructor that called SetProcessDpiAware.  Now that DirectWriteForwarder has been split off from the C# piece of PresentationCore, this module constructor lives in DirectWriteForwarder.  Due to this, the call is happening too late.

To fix this, add a module constructor back into PresentationCore via IL Injection.

* Adding InjectModuleInitializer initial targets.

Initial targets copy over ILDAsm, ILAsm, and CoreCLR bits needed to form an ILTools directory.

* Adding initial ILDAsm and ILAsm tasks and DLL assembly/disassembly targets.

* Fixing call to ILAsm to ensure it builds a DLL.

* Fixing up temp location for ILTools

* Updating packages to be RID specific and to use the latest CoreCLR packages from the COreCLR feed.

* Enabling debug in ILAsm so as to add back the Debuggable attribute.

* Switch on or off the Debuggable attribute based on the build configuration.

* Lifting inline tasks into their own code files and replacing the MSBuild based IL manipulation with C# code.

* Removing test project changes

* Fixing module constructor task to append to file.

* Removing setting of RID property as it was affecting obj/bin layout.
Fixing InjectModuleInitializer targets to use a local RID.

* Fixing module constructor creation and adding an option to use .NET Framework or .NET Core ILAsm.  This is because IL tools in .NET Core do not support debug info.

* Adding basic comments.

* Enabling module constructor injection for PresentationCore

* Fixing missing semi-colon from merge

* Creation of satellite assemblies uses PresentationCore.dll as a template to grab assembly attributes from.  Reconstructing the DLL (and injecting the module initializer) is affecting this, so we move the injection to after construction of satellites.

* Always instruct ILAsm to generate debug information, otherwise release won't have PDBs.

* Adding GitHub issue links for IL Tools modifications.
Adding exception handling for FindDotNetFrameworkILToolsTask
Fixing architecture identification (using semantics from Wpf.Cpp.Props)

* Replacing escaping with verbatim literals
Adding returns for error conditions

* Adding DARC dependencies.

* Add coherent parents for IL(D)Asm

* Coherency updates
This commit is contained in:
Rob LaDuca 2019-05-29 12:07:56 -07:00 коммит произвёл GitHub
Родитель 03b873fc81
Коммит 222874b6fe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 1231 добавлений и 99 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -332,6 +332,7 @@ ASALocalRun/
/.dotnet
/.packages
/.tools/vswhere/2.5.2
/.tools/native/iltools
### OSX ###

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

@ -6,6 +6,7 @@
<add key="myget-fxlab" value="https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json" />
<add key="arcade" value="https://dotnetfeed.blob.core.windows.net/dotnet-tools-internal/index.json" />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="dotnet-coreclr" value="https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json" />
<add key="myget-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-wd" value="https://dotnetfeed.blob.core.windows.net/dotnet-windowsdesktop/index.json" />

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

@ -1,85 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.Win32.Registry" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.CodeDom" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Configuration.ConfigurationManager" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Diagnostics.EventLog" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.DirectoryServices" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Drawing.Common" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Reflection.Emit" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Reflection.MetadataLoadContext" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Security.AccessControl" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Security.Cryptography.Xml" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Security.Permissions" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Security.Principal.Windows" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="System.Windows.Extensions" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App" Version="3.0.0-preview6-27723-08">
<Uri>https://github.com/dotnet/core-setup</Uri>
<Sha>20426e8c486d8715337cb6438ec70bc3619a514d</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19278.1">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>11f90a2a260422201895de58e57170131ab4efe7</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.CodeAnalysis" Version="1.0.0-beta.19278.1">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>11f90a2a260422201895de58e57170131ab4efe7</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.Platforms" Version="3.0.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
</Dependency>
<Dependency Name="Microsoft.Private.Winforms" Version="4.8.0-preview6.19258.6" CoherentParentDependency="Microsoft.NETCore.App">
<ProductDependencies>
<Dependency Name="Microsoft.Private.Winforms" Version="4.8.0-preview6.19279.2">
<Uri>https://github.com/dotnet/winforms</Uri>
<Sha>ee51a187ba1d2174233dacb6e2056e5403f9d36e</Sha>
<Sha>bbde30e7f09411d9c045015e8f3b6517bec2828a</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Wpf.DncEng" Version="4.8.0-preview6.19278.10">
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-wpf-int</Uri>
<Sha>15c3713f381b6208032e951e577be263152c310e</Sha>
</Dependency>
<Dependency Name="System.IO.Packaging" Version="4.6.0-preview6.19273.5" CoherentParentDependency="Microsoft.NETCore.App">
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.Win32.Registry" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>41489a93acf3f36abcaaaea2003a8fdbb577cf35</Sha>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.CodeDom" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Configuration.ConfigurationManager" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Diagnostics.EventLog" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.DirectoryServices" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Drawing.Common" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Reflection.Emit" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Reflection.MetadataLoadContext" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Security.AccessControl" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Security.Cryptography.Xml" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Security.Permissions" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Security.Principal.Windows" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="System.Windows.Extensions" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App" Version="3.0.0-preview6-27728-04">
<Uri>https://github.com/dotnet/core-setup</Uri>
<Sha>b2f8fc281df93b0ecb148224369b938d753d1616</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19270.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>3b0760f8789d5d4bd146b36bd9051696d7a56bfa</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.CodeAnalysis" Version="1.0.0-beta.19270.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>3b0760f8789d5d4bd146b36bd9051696d7a56bfa</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.Platforms" Version="3.0.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Wpf.DncEng" Version="4.8.0-preview6.19279.6">
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-wpf-int</Uri>
<Sha>db55c197391f1185a493b036b030a6b46c796f74</Sha>
</Dependency>
<Dependency Name="System.IO.Packaging" Version="4.6.0-preview6.19278.5" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/corefx</Uri>
<Sha>ac24849e0404b9a7caba56fd398dbe6c5dbede0a</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.Runtime.CoreCLR" Version="3.0.0-preview6.19278.71" CoherentParentDependency="Microsoft.NETCore.App">
<Uri>https://github.com/dotnet/coreclr</Uri>
<Sha>7631331183266734342de351b25519a07743e13e</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.ILDAsm" Version="3.0.0-preview6.19278.71" CoherentParentDependency="Microsoft.NETCore.Runtime.CoreCLR">
<Uri>https://github.com/dotnet/coreclr</Uri>
<Sha>7631331183266734342de351b25519a07743e13e</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.ILAsm" Version="3.0.0-preview6.19278.71" CoherentParentDependency="Microsoft.NETCore.Runtime.CoreCLR">
<Uri>https://github.com/dotnet/coreclr</Uri>
<Sha>7631331183266734342de351b25519a07743e13e</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>

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

@ -4,37 +4,43 @@
<VersionPrefix>4.8.0</VersionPrefix>
<PreReleaseVersionLabel>preview6</PreReleaseVersionLabel>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<SystemIOPackagingVersion>4.6.0-preview6.19273.5</SystemIOPackagingVersion>
<SystemIOPackagingVersion>4.6.0-preview6.19278.5</SystemIOPackagingVersion>
</PropertyGroup>
<!-- NuGet Package Versions -->
<PropertyGroup>
<MicrosoftPrivateWinformsVersion>4.8.0-preview6.19258.6</MicrosoftPrivateWinformsVersion>
<MicrosoftPrivateWinformsVersion>4.8.0-preview6.19279.2</MicrosoftPrivateWinformsVersion>
</PropertyGroup>
<!-- Packages that come from https://github.com/dotnet/coreclr -->
<PropertyGroup>
<MicrosoftNETCoreRuntimeCoreCLRVersion>3.0.0-preview6.19278.71</MicrosoftNETCoreRuntimeCoreCLRVersion>
<MicrosoftNETCoreILDAsmVersion>3.0.0-preview6.19278.71</MicrosoftNETCoreILDAsmVersion>
<MicrosoftNETCoreILAsmVersion>3.0.0-preview6.19278.71</MicrosoftNETCoreILAsmVersion>
</PropertyGroup>
<!-- Packages that come from https://github.com/dotnet/core-setup -->
<PropertyGroup>
<MicrosoftNETCoreAppVersion>3.0.0-preview6-27723-08</MicrosoftNETCoreAppVersion>
<MicrosoftNETCorePlatformsVersion>3.0.0-preview6.19273.5</MicrosoftNETCorePlatformsVersion>
<SystemDrawingCommonVersion>4.6.0-preview6.19273.5</SystemDrawingCommonVersion>
<SystemDirectoryServicesVersion>4.6.0-preview6.19273.5</SystemDirectoryServicesVersion>
<SystemReflectionMetadataLoadContextVersion>4.6.0-preview6.19273.5</SystemReflectionMetadataLoadContextVersion>
<MicrosoftNETCoreAppVersion>3.0.0-preview6-27728-04</MicrosoftNETCoreAppVersion>
<MicrosoftNETCorePlatformsVersion>3.0.0-preview6.19278.5</MicrosoftNETCorePlatformsVersion>
<SystemDrawingCommonVersion>4.6.0-preview6.19278.5</SystemDrawingCommonVersion>
<SystemDirectoryServicesVersion>4.6.0-preview6.19278.5</SystemDirectoryServicesVersion>
<SystemReflectionMetadataLoadContextVersion>4.6.0-preview6.19278.5</SystemReflectionMetadataLoadContextVersion>
</PropertyGroup>
<!-- Packages that come from https://github.com/dotnet/corefx via core-setup coherency parent dependency -->
<PropertyGroup>
<MicrosoftWin32RegistryPackageVersion>4.6.0-preview6.19273.5</MicrosoftWin32RegistryPackageVersion>
<SystemCodeDomPackageVersion>4.6.0-preview6.19273.5</SystemCodeDomPackageVersion>
<SystemConfigurationConfigurationManagerPackageVersion>4.6.0-preview6.19273.5</SystemConfigurationConfigurationManagerPackageVersion>
<SystemDiagnosticsEventLogPackageVersion>4.6.0-preview6.19273.5</SystemDiagnosticsEventLogPackageVersion>
<SystemReflectionEmitPackageVersion>4.6.0-preview6.19273.5</SystemReflectionEmitPackageVersion>
<MicrosoftWin32RegistryPackageVersion>4.6.0-preview6.19278.5</MicrosoftWin32RegistryPackageVersion>
<SystemCodeDomPackageVersion>4.6.0-preview6.19278.5</SystemCodeDomPackageVersion>
<SystemConfigurationConfigurationManagerPackageVersion>4.6.0-preview6.19278.5</SystemConfigurationConfigurationManagerPackageVersion>
<SystemDiagnosticsEventLogPackageVersion>4.6.0-preview6.19278.5</SystemDiagnosticsEventLogPackageVersion>
<SystemReflectionEmitPackageVersion>4.6.0-preview6.19278.5</SystemReflectionEmitPackageVersion>
<SystemReflectionTypeExtensionsPackageVersion>4.6.0-preview4.19176.11</SystemReflectionTypeExtensionsPackageVersion>
<SystemSecurityAccessControlPackageVersion>4.6.0-preview6.19273.5</SystemSecurityAccessControlPackageVersion>
<SystemSecurityCryptographyXmlPackageVersion>4.6.0-preview6.19273.5</SystemSecurityCryptographyXmlPackageVersion>
<SystemSecurityPermissionsPackageVersion>4.6.0-preview6.19273.5</SystemSecurityPermissionsPackageVersion>
<SystemSecurityPrincipalWindowsPackageVersion>4.6.0-preview6.19273.5</SystemSecurityPrincipalWindowsPackageVersion>
<SystemWindowsExtensionsPackageVersion>4.6.0-preview6.19273.5</SystemWindowsExtensionsPackageVersion>
<SystemSecurityAccessControlPackageVersion>4.6.0-preview6.19278.5</SystemSecurityAccessControlPackageVersion>
<SystemSecurityCryptographyXmlPackageVersion>4.6.0-preview6.19278.5</SystemSecurityCryptographyXmlPackageVersion>
<SystemSecurityPermissionsPackageVersion>4.6.0-preview6.19278.5</SystemSecurityPermissionsPackageVersion>
<SystemSecurityPrincipalWindowsPackageVersion>4.6.0-preview6.19278.5</SystemSecurityPrincipalWindowsPackageVersion>
<SystemWindowsExtensionsPackageVersion>4.6.0-preview6.19278.5</SystemWindowsExtensionsPackageVersion>
</PropertyGroup>
<!-- Packages that come from https://github.com/dotnet/arcade -->
<PropertyGroup>
<MicrosoftDotNetCodeAnalysisPackageVersion>1.0.0-beta.19278.1</MicrosoftDotNetCodeAnalysisPackageVersion>
<MicrosoftDotNetCodeAnalysisPackageVersion>1.0.0-beta.19270.2</MicrosoftDotNetCodeAnalysisPackageVersion>
</PropertyGroup>
<!-- Packages that come from https://github.com/dotnet/corefxlab -->
<PropertyGroup>
@ -57,8 +63,9 @@
<RestoreSources>
$(RestoreSources);
https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-windowsdesktop/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-windowsdesktop/index.json
</RestoreSources>
</PropertyGroup>
<!--Package names-->
@ -91,6 +98,6 @@
It is worth reiterating that this package *should not* be consumed to build the product.
-->
<PropertyGroup>
<MicrosoftDotNetWpfDncEngVersion>4.8.0-preview6.19278.10</MicrosoftDotNetWpfDncEngVersion>
<MicrosoftDotNetWpfDncEngVersion>4.8.0-preview6.19279.6</MicrosoftDotNetWpfDncEngVersion>
</PropertyGroup>
</Project>

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

@ -20,6 +20,7 @@
<Import Project="$(WpfArcadeSdkToolsDir)CodeAnalysis.targets" />
<Import Project="$(WpfArcadeSdkToolsDir)Wpf.Cpp.targets" Condition="'$(MSBuildProjectExtension)'=='.vcxproj'"/>
<Import Project="$(NoTargetsTargets)" Condition="'$(NoTargets)'=='true'"/>
<Import Project="$(WpfArcadeSdkToolsDir)InjectModuleInitializer.targets" Condition="'$(InjectModuleInitializer)'=='true'"/>
<Import Project="$(WpfArcadeSdkToolsDir)TestProjects.targets" />
<!-- PresentationBuildTasks related targets files -->

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

@ -0,0 +1,428 @@
<Project>
<!-- We use a local RID here since we don't want to change the build layout by setting the actual RID. -->
<PropertyGroup>
<LocalRuntimeIdentifier Condition="'$(Platform)'=='x64' or '$(Platform)'=='x86' or '$(Platform)'=='arm' or '$(Platform)'=='arm64'">win-$(Platform)</LocalRuntimeIdentifier>
<LocalRuntimeIdentifier Condition="'$(Platform)'=='Win32' or '$(Platform)'=='AnyCPU'">win-x86</LocalRuntimeIdentifier>
<LocalRuntimeIdentifier Condition="'$(Architecture)'==''">win-x64</LocalRuntimeIdentifier>
</PropertyGroup>
<Choose>
<!--
Use the IL Tools that are compiled and distributed with .NET Core. WPF doesn't currently use these as default because they do not
support generating debugging information in the re-assembled binary.
-->
<When Condition="'$(UseNetCoreILTools)'=='true'">
<ItemGroup>
<PackageReference Include="$(PackageRuntimeIdentifierPrefix).Microsoft.NETCore.ILDAsm" Version="MicrosoftNETCoreILDAsmVersion" GeneratePathProperty="true" />
<PackageReference Include="$(PackageRuntimeIdentifierPrefix).Microsoft.NETCore.ILAsm" Version="MicrosoftNETCoreILAsmVersion" GeneratePathProperty="true" />
<PackageReference Include="$(PackageRuntimeIdentifierPrefix).Microsoft.NETCore.Runtime.CoreCLR" Version="MicrosoftNETCoreRuntimeCoreCLRVersion" GeneratePathProperty="true" />
</ItemGroup>
<PropertyGroup Condition="'$(LocalRuntimeIdentifier)'=='win-x86'">
<ILDAsmPath>$(Pkgruntime_win-x86_Microsoft_NETCore_ILDAsm)\runtimes\$(LocalRuntimeIdentifier)\native\</ILDAsmPath>
<ILAsmPath>$(Pkgruntime_win-x86_Microsoft_NETCore_ILAsm)\runtimes\$(LocalRuntimeIdentifier)\native\</ILAsmPath>
<CoreCLRPath>$(Pkgruntime_win-x86_Microsoft_NETCore_Runtime_CoreCLR)\runtimes\$(LocalRuntimeIdentifier)\native\</CoreCLRPath>
</PropertyGroup>
<PropertyGroup Condition="'$(LocalRuntimeIdentifier)'=='win-x64'">
<ILDAsmPath>$(Pkgruntime_win-x64_Microsoft_NETCore_ILDAsm)\runtimes\$(LocalRuntimeIdentifier)\native\</ILDAsmPath>
<ILAsmPath>$(Pkgruntime_win-x64_Microsoft_NETCore_ILAsm)\runtimes\$(LocalRuntimeIdentifier)\native\</ILAsmPath>
<CoreCLRPath>$(Pkgruntime_win-x64_Microsoft_NETCore_Runtime_CoreCLR)\runtimes\$(LocalRuntimeIdentifier)\native\</CoreCLRPath>
</PropertyGroup>
<PropertyGroup>
<ILToolsPath>$(ArtifactsTmpDir)\iltools\$(PackageRuntimeIdentifierPrefix)\</ILToolsPath>
<ILDAsm>$(ILToolsPath)ildasm.exe</ILDAsm>
<ILAsm>$(ILToolsPath)ilasm.exe</ILAsm>
</PropertyGroup>
</When>
</Choose>
<PropertyGroup>
<TaskFactory>RoslynCodeTaskFactory</TaskFactory>
<TaskFactoryAssemblyFile>$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</TaskFactoryAssemblyFile>
</PropertyGroup>
<ItemGroup>
<TaskFactoryReference Include="mscorlib" />
<TaskFactoryReference Include="netstandard" />
</ItemGroup>
<!--
Locate the IL tools included with the highest version of .NET Framework and the .NET Framework SDK installed on the machine.
-->
<UsingTask TaskName="FindDotNetFrameworkILToolsTask"
TaskFactory="$(TaskFactory)"
AssemblyFile="$(TaskFactoryAssemblyFile)">
<ParameterGroup>
<ILAsm ParameterType="System.String" Output="true"/>
<ILDAsm ParameterType="System.String" Output="true"/>
<DotNetBitness ParameterType="System.String" Required="true"/>
</ParameterGroup>
<Task>
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="fragment" Language="cs">
<![CDATA[
try
{
var bitness = (DotNetFrameworkArchitecture)Enum.Parse(typeof(DotNetFrameworkArchitecture), DotNetBitness);
ILAsm = ToolLocationHelper.GetPathToDotNetFrameworkFile("ILAsm.exe", TargetDotNetFrameworkVersion.VersionLatest, bitness);
ILDAsm = ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("ILDAsm.exe", TargetDotNetFrameworkVersion.VersionLatest, bitness);
}
catch(Exception e)
{
Log.LogError("FindDotNetFrameworkILToolsTask: Could not find .NET Framework IL Tools: " + e.ToString());
}
]]>
</Code>
</Task>
</UsingTask>
<!-- Call into the supplied ILDAsm. -->
<UsingTask TaskName="ILDasmTask"
TaskFactory="$(TaskFactory)"
AssemblyFile="$(TaskFactoryAssemblyFile)">
<ParameterGroup>
<ILDAsm ParameterType="System.String" Required="true" />
<!-- The assembly to disassemble -->
<Assembly ParameterType="System.String" Required="true" />
<Out ParameterType="System.String" Required="true" Output="true" />
<!-- Output in HTML format -->
<Html ParameterType="System.Boolean" Required="false" />
<!-- Output in rich text format -->
<Rtf ParameterType="System.Boolean" Required="false" />
<!-- Show actual bytes (in hex) as instruction comments -->
<Bytes ParameterType="System.Boolean" Required="false" />
<!-- Show exception handling clauses in raw form -->
<RawEH ParameterType="System.Boolean" Required="false" />
<!-- Show metadata tokens of classes and members -->
<Tokens ParameterType="System.Boolean" Required="false" />
<!-- Show original source lines as comments -->
<Source ParameterType="System.Boolean" Required="false" />
<!-- Include references to original source lines -->
<LineNum ParameterType="System.Boolean" Required="false" />
<!-- =<vis>[+<vis>...] Only disassemble the items with specified
visibility. (<vis> = PUB | PRI | FAM | ASM | FAA | FOA | PSC)
-->
<Visibility ParameterType="System.String" Required="false" />
<!-- Only disassemble the public items (same as /VIS=PUB) -->
<PubOnly ParameterType="System.Boolean" Required="false" />
<!-- Include all names into single quotes -->
<QuoteAllNames ParameterType="System.Boolean" Required="false" />
<!-- Suppress output of custom attributes -->
<NoCA ParameterType="System.Boolean" Required="false" />
<!-- Output CA blobs in verbal form (default - in binary form) -->
<CAVerbal ParameterType="System.Boolean" Required="false" />
<!-- Suppress disassembly progress bar window pop-up -->
<NoBar ParameterType="System.Boolean" Required="false" />
<!-- Use UTF-8 encoding for output (default - ANSI) -->
<Utf8 ParameterType="System.Boolean" Required="false" />
<!-- Use UNICODE encoding for output -->
<Unicode ParameterType="System.Boolean" Required="false" />
<!-- Suppress IL assembler code output -->
<NoIL ParameterType="System.Boolean" Required="false" />
<!-- Use forward class declaration -->
<Forward ParameterType="System.Boolean" Required="false" />
<!-- Output full list of types (to preserve type ordering in round-trip) -->
<TypeList ParameterType="System.Boolean" Required="false" />
<!-- Display .NET projection view if input is a .winmd file -->
<Project ParameterType="System.Boolean" Required="false" />
<!-- Include file headers information in the output -->
<Headers ParameterType="System.Boolean" Required="false" />
<!-- =<class>[::<method>[(<sig>)] Disassemble the specified item only -->
<Item ParameterType="System.String" Required="false" />
<!-- Include statistics on the image -->
<Stats ParameterType="System.Boolean" Required="false" />
<!-- Include list of classes defined in the module -->
<ClassList ParameterType="System.Boolean" Required="false" />
<!-- Combination of /HEADER,/BYTES,/STATS,/CLASSLIST,/TOKENS -->
<All ParameterType="System.Boolean" Required="false" />
<!--
Options for EXE,DLL,OBJ and LIB files:
/METADATA[=<specifier>] Show MetaData, where <specifier> is:
MDHEADER Show MetaData header information and sizes.
HEX Show more things in hex as well as words.
CSV Show the record counts and heap sizes.
UNREX Show unresolved externals.
SCHEMA Show the MetaData header and schema information.
RAW Show the raw MetaData tables.
HEAPS Show the raw heaps.
VALIDATE Validate the consistency of the metadata.
-->
<Metadata ParameterType="System.String" Required="false" />
<!--
Options for LIB files only:
/OBJECTFILE=<obj_file_name> Show MetaData of a single object file in library
-->
<ObjectFile ParameterType="System.String" Required="false" />
</ParameterGroup>
<Task>
<Code Type="Class" Language="cs" Source="$(WpfArcadeSdkToolsDir)InjectModuleInitializer\ILDAsmTask.cs" />
</Task>
</UsingTask>
<!-- Call into the supplied ILAsm. -->
<UsingTask TaskName="ILAsmTask"
TaskFactory="$(TaskFactory)"
AssemblyFile="$(TaskFactoryAssemblyFile)">
<ParameterGroup>
<ILAsm ParameterType="System.String" Required="true" />
<SourceFile ParameterType="System.String" Required="true" />
<Out ParameterType="System.String" Required="true" Output="true" />
<!-- /NOLOGO Don't type the logo -->
<NoLogo ParameterType="System.Boolean" Required="false" />
<!--/QUIET Don't report assembly progress -->
<Quiet ParameterType="System.Boolean" Required="false" />
<!--/NOAUTOINHERIT Disable inheriting from System.Object by default-->
<NoAutoInherit ParameterType="System.Boolean" Required="false" />
<!--/DLL Compile to .dll-->
<Dll ParameterType="System.Boolean" Required="false" />
<!--/EXE Compile to .exe (default)-->
<Exe ParameterType="System.Boolean" Required="false" />
<!--/PDB Create the PDB file without enabling debug info tracking-->
<Pdb ParameterType="System.Boolean" Required="false" />
<!--/APPCONTAINER Create an AppContainer exe or dll-->
<AppContainer ParameterType="System.Boolean" Required="false" />
<!--/DEBUG Disable JIT optimization, create PDB file, use sequence points from PDB-->
<Debug ParameterType="System.Boolean" Required="false" />
<!--/DEBUG=IMPL Disable JIT optimization, create PDB file, use implicit sequence points-->
<DebugDisableJitOptimization ParameterType="System.Boolean" Required="false" />
<!--/DEBUG=OPT Enable JIT optimization, create PDB file, use implicit sequence points -->
<DebugEnableJitOptimization ParameterType="System.Boolean" Required="false" />
<!--/OPTIMIZE Optimize long instructions to short-->
<Optimize ParameterType="System.Boolean" Required="false" />
<!--/FOLD Fold the identical method bodies into one-->
<Fold ParameterType="System.Boolean" Required="false" />
<!--/CLOCK Measure and report compilation times-->
<Clock ParameterType="System.Boolean" Required="false" />
<!--/RESOURCE=<res_file> Link the specified resource file (*.res) into resulting .exe or .dll -->
<Resource ParameterType="System.String" Required="false" />
<!--/CVRES=<path_to_file> Set path to cvtres tool: /CVR=cvtres.exe /CVR=tool\cvtres.cmd /CVR=D:\tool\-->
<CvRes ParameterType="System.String" Required="false" />
<!--/KEY=<keyfile> Compile with strong signature
(<keyfile> contains private key)-->
<KeyFile ParameterType="System.String" Required="false" />
<!--/KEY=@<keysource> Compile with strong signature
(<keysource> is the private key source name)-->
<KeySource ParameterType="System.String" Required="false" />
<!--/INCLUDE=<path> Set path to search for #include'd files-->
<Include ParameterType="System.String" Required="false" />
<!--/SUBSYSTEM=<int> Set Subsystem value in the NT Optional header-->
<SubSystem ParameterType="System.String" Required="false" />
<!--/SSVER=<int>.<int> Set Subsystem version number in the NT Optional header-->
<SubSystemVersion ParameterType="System.String" Required="false" />
<!--/FLAGS=<int> Set CLR ImageFlags value in the CLR header-->
<Flags ParameterType="System.String" Required="false" />
<!--/ALIGNMENT=<int> Set FileAlignment value in the NT Optional header-->
<Alignment ParameterType="System.String" Required="false" />
<!--/BASE=<int> Set ImageBase value in the NT Optional header (max 2GB for 32-bit images)-->
<Base ParameterType="System.String" Required="false" />
<!--/STACK=<int> Set SizeOfStackReserve value in the NT Optional header-->
<Stack ParameterType="System.String" Required="false" />
<!--/MDV=<version_string> Set Metadata version string-->
<MetadataVersion ParameterType="System.String" Required="false" />
<!--/MSV=<int>.<int> Set Metadata stream version (<major>.<minor>)-->
<MetadataStreamVersion ParameterType="System.String" Required="false" />
<!--/PE64 Create a 64bit image (PE32+)-->
<PE64 ParameterType="System.String" Required="false" />
<!--/HIGHENTROPYVA Set High Entropy Virtual Address capable PE32+ images (default for /APPCONTAINER)-->
<HighEntropyVirtualAddress ParameterType="System.String" Required="false" />
<!--/NOCORSTUB Suppress generation of CORExeMain stub-->
<NoCorStub ParameterType="System.String" Required="false" />
<!--/STRIPRELOC Indicate that no base relocations are needed-->
<StripReLoc ParameterType="System.String" Required="false" />
<!--/ITANIUM Target processor: Intel Itanium-->
<Itanium ParameterType="System.String" Required="false" />
<!--/X64 Target processor: 64bit AMD processor-->
<X64 ParameterType="System.String" Required="false" />
<!--/ARM Target processor: ARM processor-->
<Arm ParameterType="System.String" Required="false" />
<!--/32BITPREFERRED Create a 32BitPreferred image (PE32)-->
<Prefer32Bit ParameterType="System.String" Required="false" />
<!--/ENC=<file> Create Edit-and-Continue deltas from specified source file-->
<ENC ParameterType="System.String" Required="false" />
</ParameterGroup>
<Task>
<Code Type="Class" Language="cs" Source="$(WpfArcadeSdkToolsDir)InjectModuleInitializer\ILAsmTask.cs" />
</Task>
</UsingTask>
<!-- Add a module initializer to the supplied IL file. -->
<UsingTask TaskName="AddModuleConstructorTask"
TaskFactory="$(TaskFactory)"
AssemblyFile="$(TaskFactoryAssemblyFile)">
<ParameterGroup>
<ILFile ParameterType="System.String" Required="true" Output="true"/>
<MsCorLibAssemblySectionIL ParameterType="System.String" Required="true" Output="true"/>
<ModuleConstructorIL ParameterType="System.String" Required="true" Output="true"/>
</ParameterGroup>
<Task>
<Code Type="Class" Language="cs" Source="$(WpfArcadeSdkToolsDir)InjectModuleInitializer\AddModuleConstructorTask.cs" />
</Task>
</UsingTask>
<!--
In order to run ILDAsm and ILAsm from .NET Core, we need both the IL* executables and the corresponding version
of CoreCLR in the same directory. This target ensures that for every project using module initializer
injection.
See: https://github.com/dotnet/coreclr/issues/23840 and https://github.com/dotnet/coreclr/issues/15059
-->
<Target Name="CopyILTools" BeforeTargets="DeconstructDll" Condition="'$(UseNetCoreILTools)'=='true'">
<ItemGroup>
<ILDAsm_Files Include="$(ILDAsmPath)*"/>
<ILAsm_Files Include="$(ILAsmPath)*"/>
<CoreCLR_Files Include="$(CoreCLRPath)*"/>
</ItemGroup>
<MakeDir Directories="$(ILToolsPath)" Condition="!Exists($(ILToolsPath))"/>
<Copy SourceFiles="@(ILDAsm_Files)" DestinationFolder="$(ILToolsPath)" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(ILAsm_Files)" DestinationFolder="$(ILToolsPath)" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(CoreCLR_Files)" DestinationFolder="$(ILToolsPath)" SkipUnchangedFiles="true"/>
</Target>
<!--
Locate the IL tools included with the highest version of .NET Framework and the .NET Framework SDK installed on the machine.
-->
<Target Name="FindNetFrameworkILTools" BeforeTargets="DeconstructDll" Condition="'$(UseNetCoreILTools)'!='true'">
<PropertyGroup>
<DotNetFrameworkBitness Condition="'$(LocalRuntimeIdentifier)'=='win-x64'">Bitness64</DotNetFrameworkBitness>
<DotNetFrameworkBitness Condition="'$(LocalRuntimeIdentifier)'=='win-x86'">Bitness32</DotNetFrameworkBitness>
</PropertyGroup>
<FindDotNetFrameworkILToolsTask DotNetBitness="$(DotNetFrameworkBitness)">
<Output TaskParameter="ILDAsm" PropertyName="ILDAsm" />
<Output TaskParameter="ILAsm" PropertyName="ILAsm" />
</FindDotNetFrameworkILToolsTask>
</Target>
<!-- Disassemble the target binary. -->
<Target Name="DeconstructDll"
AfterTargets="CreateSatelliteAssemblies"
Inputs="$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)'))"
Outputs="$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName).il'))">
<PropertyGroup>
<InFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)'))</InFile>
<OutFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName).il'))</OutFile>
</PropertyGroup>
<Delete Files="$(OutFile)"
Condition="Exists('$(OutFile)')" />
<ILDasmTask ILDAsm="$(ILDAsm)"
Assembly="$(InFile)"
Condition="Exists('$(InFile)')"
LineNum="true"
Out="$(OutFile)" />
</Target>
<!-- Inject the module initializer into the target IL. -->
<Target Name="AddModuleConstructor"
AfterTargets="DeconstructDll">
<PropertyGroup>
<ILFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName).il'))</ILFile>
<ModuleInitializer>$(WpfArcadeSdkToolsDir)InjectModuleInitializer\ModuleInitializer.il</ModuleInitializer>
<MsCorLibAssemblySection>$(WpfArcadeSdkToolsDir)InjectModuleInitializer\MsCorLibAssemblySection.il</MsCorLibAssemblySection>
</PropertyGroup>
<AddModuleConstructorTask ILFile="$(ILFile)"
MsCorLibAssemblySectionIL="$(ModuleInitializer)"
ModuleConstructorIL="$(MsCorLibAssemblySection)"/>
</Target>
<!-- Re-assembly the target binary. -->
<Target Name="ReconstituteDll"
AfterTargets="AddModuleConstructor"
Inputs="$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName).il'))"
Outputs="$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)'))">
<PropertyGroup>
<TargetFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)'))</TargetFile>
<ILFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)$(AssemblyName).il'))</ILFile>
</PropertyGroup>
<!--
Make a backup before overwriting $(TargetFile)
-->
<Copy SourceFiles="$(TargetFile)"
DestinationFiles="$(TargetFile).bak"
Condition="Exists('$(TargetFile)')" />
<ILAsmTask ILAsm="$(ILAsm)"
SourceFile="$(ILFile)"
Out="$(TargetFile)"
Dll="true"
Debug="true" />
</Target>
</Project>

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

@ -0,0 +1,80 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace WpfArcadeSdk.Build.Tasks
{
/// <summary>
/// Append the supplied module constructor to the supplied IL file.
/// Using this requires that the DLL has implemented a static class named
/// ModuleInitializer with a static void Initialize function. This class
/// is called from the module initializer.
/// </summary>
public class AddModuleConstructorTask : Task
{
/// <summary>
/// The original IL file to manipulate
/// </summary>
[Required]
public string ILFile { get; set; }
/// <summary>
/// Contains the IL section referencing mscorlib.
/// This is inserted if not already present.
/// </summary>
[Required]
public string MsCorLibAssemblySectionIL { get; set; }
/// <summary>
/// Contains the IL of the module constructor
/// </summary>
[Required]
public string ModuleConstructorIL { get; set; }
public override bool Execute()
{
try
{
var moduleConstructorIL = File.ReadAllText(ModuleConstructorIL);
var msCorLibAssemblySectionIL = File.ReadAllText(MsCorLibAssemblySectionIL);
var sourceIL = File.ReadAllText(ILFile);
using (var outputIL = new StreamWriter(File.Open(ILFile, FileMode.Truncate)))
{
if (Regex.Match(sourceIL, @"\.class.+?ModuleInitializer.+?\.method.+?static.+?Initialize\(\).+?end of class ModuleInitializer", RegexOptions.Singleline) == Match.Empty)
{
Log.LogError("Inserting a module initializer requires the assembly to implement a class named ModuleInitializer with a static parameterless method named Initialize.");
return false;
}
if (Regex.Match(sourceIL, @"\.assembly extern mscorlib", RegexOptions.Singleline) == Match.Empty)
{
outputIL.WriteLine(msCorLibAssemblySectionIL);
}
if (Regex.Match(sourceIL, @"\.class private auto ansi '\<Module\>'.+?\.method private hidebysig specialname rtspecialname static void \.cctor \(\) cil managed ", RegexOptions.Singleline) == Match.Empty)
{
outputIL.WriteLine(moduleConstructorIL);
}
else
{
Log.LogError("Cannot insert a module initializer into an assembly that already contains one.");
return false;
}
outputIL.WriteLine(sourceIL);
}
return true;
}
catch (Exception e)
{
Log.LogError(e.ToString() + Environment.NewLine + e.StackTrace);
return false;
}
}
}
}

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

@ -0,0 +1,301 @@
using System;
using System.Diagnostics;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace WpfArcadeSdk.Build.Tasks
{
/// <summary>
/// Runs ILAsm from the path supplied on the assembly supplied.
/// </summary>
public class ILAsmTask : Task
{
/// <summary>
/// The full path to ILAsm.exe
/// </summary>
[Required]
public string ILAsm { get; set; }
/// <summary>
/// The source file to assemble
/// </summary>
[Required]
public string SourceFile { get; set; }
/// <summary>
/// The output path
/// </summary>
[Required]
public string Out { get; set; }
/// <summary>
/// /NOLOGO Don't type the logo
///</summary>
public bool NoLogo { get; set; }
/// <summary>
/// /QUIET Don't report assembly progress
///</summary>
public bool Quiet { get; set; }
/// <summary>
/// /NOAUTOINHERIT Disable inheriting from System.Object by default
///</summary>
public bool NoAutoInherit { get; set; }
/// <summary>
/// /DLL Compile to.dll
///</summary>
public bool Dll { get; set; }
/// <summary>
/// /EXE Compile to.exe(default)
///</summary>
public bool Exe { get; set; }
/// <summary>
/// /PDB Create the PDB file without enabling debug info tracking
///</summary>
public bool Pdb { get; set; }
/// <summary>
/// /APPCONTAINER Create an AppContainer exe or dll
///</summary>
public bool AppContainer { get; set; }
/// <summary>
/// /DEBUG Disable JIT optimization, create PDB file, use sequence points from PDB
///</summary>
public bool Debug { get; set; }
/// <summary>
/// /DEBUG=IMPL Disable JIT optimization, create PDB file, use implicit sequence points
///</summary>
public bool DebugDisableJitOptimization { get; set; }
/// <summary>
/// / DEBUG = OPT Enable JIT optimization, create PDB file, use implicit sequence points
///</summary>
public bool DebugEnableJitOptimization { get; set; }
/// <summary>
/// / OPTIMIZE Optimize long instructions to short
///</summary>
public bool Optimize { get; set; }
/// <summary>
/// / FOLD Fold the identical method bodies into one
///</summary>
public bool Fold { get; set; }
/// <summary>
/// / CLOCK Measure and report compilation times
///</summary>
public bool Clock { get; set; }
/// <summary>
/// / RESOURCE =< res_file > Link the specified resource file(*.res) into resulting.exe or.dll
///</summary>
public string Resource { get; set; }
/// <summary>
/// / CVRES =< path_to_file > Set path to cvtres tool: /CVR= cvtres.exe / CVR = tool\cvtres.cmd /CVR= D:\tool\
///</summary>
public string CvRes { get; set; }
/// <summary>
/// /KEY =< keyfile > Compile with strong signature
/// (<keyfile> contains private key)
/// </summary>
public string KeyFile { get; set; }
/// <summary>
/// /KEY=@<keysource> Compile with strong signature
/// (<keysource> is the private key source name)
/// </summary>
public string KeySource { get; set; }
/// <summary>
/// /INCLUDE=<path> Set path to search for #include'd files
///</summary>
public string Include { get; set; }
/// <summary>
/// /SUBSYSTEM=<int> Set Subsystem value in the NT Optional header
///</summary>
public string SubSystem { get; set; }
/// <summary>
/// /SSVER=<int>.<int> Set Subsystem version number in the NT Optional header
///</summary>
public string SubSystemVersion { get; set; }
/// <summary>
/// /FLAGS=<int> Set CLR ImageFlags value in the CLR header
///</summary>
public string Flags { get; set; }
/// <summary>
/// /ALIGNMENT=<int> Set FileAlignment value in the NT Optional header
///</summary>
public string Alignment { get; set; }
/// <summary>
/// /BASE=<int> Set ImageBase value in the NT Optional header(max 2GB for 32-bit images)
///</summary>
public string Base { get; set; }
/// <summary>
/// /STACK=<int> Set SizeOfStackReserve value in the NT Optional header
///</summary>
public string Stack { get; set; }
/// <summary>
/// /MDV=<version_string> Set Metadata version string
///</summary>
public string MetadataVersion { get; set; }
/// <summary>
/// /MSV=<int>.<int> Set Metadata stream version(<major>.<minor>)
///</summary>
public string MetadataStreamVersion { get; set; }
/// <summary>
/// /PE64 Create a 64bit image(PE32+)
///</summary>
public string PE64 { get; set; }
/// <summary>
/// /HIGHENTROPYVA Set High Entropy Virtual Address capable PE32+ images(default for /APPCONTAINER)
///</summary>
public string HighEntropyVirtualAddress { get; set; }
/// <summary>
/// /NOCORSTUB Suppress generation of CORExeMain stub
///</summary>
public string NoCorStub { get; set; }
/// <summary>
/// /STRIPRELOC Indicate that no base relocations are needed
///</summary>
public string StripReLoc { get; set; }
/// <summary>
/// /ITANIUM Target processor: Intel Itanium
///</summary>
public string Itanium { get; set; }
/// <summary>
/// /X64 Target processor: 64bit AMD processor
///</summary>
public string X64 { get; set; }
/// <summary>
/// /ARM Target processor: ARM processor
///</summary>
public string Arm { get; set; }
/// <summary>
/// /32BITPREFERRED Create a 32BitPreferred image(PE32)
///</summary>
public string Prefer32Bit { get; set; }
/// <summary>
/// /ENC=<file> Create Edit-and-Continue deltas from specified source file
///</summary>
public string ENC { get; set; }
public override bool Execute()
{
try
{
string commandLine = "/OUT=" + Out;
if (NoLogo) commandLine += " /NOLOGO";
if (Quiet) commandLine += " /QUIET";
if (NoAutoInherit) commandLine += " /NOAUTOINHERIT";
if (Dll) commandLine += " /DLL";
if (Exe) commandLine += " /EXE";
if (Pdb) commandLine += " /PDB";
if (AppContainer) commandLine += " /APPCONTAINER";
if (Debug) commandLine += " /DEBUG";
if (DebugDisableJitOptimization) commandLine += " /DEBUG=IMPL";
if (DebugEnableJitOptimization) commandLine += " /DEBUG=OPT";
if (Optimize) commandLine += " /OPTIMIZE";
if (Fold) commandLine += " /FOLD";
if (Clock) commandLine += " /CLOCK";
if (!string.IsNullOrEmpty(Resource)) commandLine += " /RESOURCE=" + Resource;
if (!string.IsNullOrEmpty(CvRes)) commandLine += " /CVRES=" + CvRes;
if (!string.IsNullOrEmpty(KeyFile)) commandLine += " /KeyFile=" + KeyFile;
if (!string.IsNullOrEmpty(KeySource)) commandLine += " /CVRES=@" + KeySource;
if (!string.IsNullOrEmpty(Include)) commandLine += " /INCLUDE=" + Include;
int subSystem = -1;
if (!string.IsNullOrEmpty(SubSystem) && Int32.TryParse(SubSystem, out subSystem)) commandLine += " /SUBSYSTEM=" + subSystem;
if (!string.IsNullOrEmpty(SubSystemVersion)) commandLine += " /SUBSYSTEMVERSION=" + SubSystemVersion;
int flags = -1;
if (!string.IsNullOrEmpty(Flags) && Int32.TryParse(Flags, out flags)) commandLine += " /FLAGS=" + flags;
int alignment = -1;
if (!string.IsNullOrEmpty(Alignment) && Int32.TryParse(Alignment, out alignment)) commandLine += " /ALIGNMENT=" + alignment;
int @base = -1;
if (!string.IsNullOrEmpty(Base) && Int32.TryParse(Base, out @base)) commandLine += " /BASE=" + @base;
int stack = -1;
if (!string.IsNullOrEmpty(Stack) && Int32.TryParse(Stack, out stack)) commandLine += " /STACK=" + stack;
if (!string.IsNullOrEmpty(MetadataVersion)) commandLine += " /MDV=" + MetadataVersion;
if (!string.IsNullOrEmpty(MetadataStreamVersion)) commandLine += " /MSV=" + MetadataStreamVersion;
bool pe64 = false;
if (!string.IsNullOrEmpty(PE64) && bool.TryParse(PE64, out pe64)) commandLine += " /PE64=" + pe64;
bool highEntropyVA = false;
if (!string.IsNullOrEmpty(HighEntropyVirtualAddress) && bool.TryParse(HighEntropyVirtualAddress, out highEntropyVA)) commandLine += " /HIGHENTROPYVA=" + highEntropyVA;
bool noCorStub = false;
if (!string.IsNullOrEmpty(NoCorStub) && bool.TryParse(NoCorStub, out noCorStub)) commandLine += " /NOCORSTUB=" + noCorStub;
bool stripreloc = false;
if (!string.IsNullOrEmpty(StripReLoc) && bool.TryParse(StripReLoc, out stripreloc)) commandLine += " /STRIPRELOC=" + stripreloc;
bool itanium = false;
if (!string.IsNullOrEmpty(Itanium) && bool.TryParse(Itanium, out itanium)) commandLine += " /ITANIUM=" + itanium;
bool x64 = false;
if (!string.IsNullOrEmpty(X64) && bool.TryParse(X64, out x64)) commandLine += " /X64=" + x64;
bool arm = false;
if (!string.IsNullOrEmpty(Arm) && bool.TryParse(Arm, out arm)) commandLine += " /ARM=" + arm;
bool prefer32bit = false;
if (!string.IsNullOrEmpty(Prefer32Bit) && bool.TryParse(Prefer32Bit, out prefer32bit)) commandLine += " /32BITPREFERRED=" + prefer32bit;
if (!string.IsNullOrEmpty(ENC)) commandLine += " /ENC=" + ENC;
ProcessStartInfo startInfo = new ProcessStartInfo(ILAsm);
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = SourceFile + " " + commandLine;
Log.LogMessage("Starting process: " + startInfo.FileName + " " + startInfo.Arguments);
Process.Start(startInfo).WaitForExit();
return true;
}
catch (Exception e)
{
Log.LogError(e.ToString() + e.StackTrace);
return false;
}
}
}
}

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

@ -0,0 +1,212 @@
using System;
using System.Diagnostics;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace WpfArcadeSdk.Build.Tasks
{
/// <summary>
/// Runs ILDAsm from the path supplied on the assembly supplied.
/// </summary>
public class ILDAsmTask : Task
{
[Required]
public string ILDAsm { get; set; }
[Required]
public string Assembly { get; set; }
[Required]
public string Out { get; set; }
/// <summary>
/// Output in HTML format
///</summary>
public bool Html { get; set; }
/// <summary>
/// Output in rich text format
///</summary>
public bool Rtf { get; set; }
/// <summary>
/// Show actual bytes(in hex) as instruction comments
///</summary>
public bool Bytes { get; set; }
/// <summary>
/// Show exception handling clauses in raw form
///</summary>
public bool RawEH { get; set; }
/// <summary>
/// Show metadata tokens of classes and members
///</summary>
public bool Tokens { get; set; }
/// <summary>
/// Show original source lines as comments
///</summary>
public bool Source { get; set; }
/// <summary>
/// Include references to original source lines
///</summary>
public bool LineNum { get; set; }
/// <summary>
/// =<vis>[+<vis>...] Only disassemble the items with specified
/// visibility. (<vis> = PUB | PRI | FAM | ASM | FAA | FOA | PSC)
/// </summary>
public string Visibility { get; set; }
/// <summary>
/// Only disassemble the public items(same as /VIS= PUB)
///</summary>
public bool PubOnly { get; set; }
/// <summary>
/// Include all names into single quotes
///</summary>
public bool QuoteAllNames { get; set; }
/// <summary>
/// Suppress output of custom attributes
///</summary>
public bool NoCA { get; set; }
/// <summary>
/// Output CA blobs in verbal form(default - in binary form)
///</summary>
public bool CAVerbal { get; set; }
/// <summary>
/// Suppress disassembly progress bar window pop-up
///</summary>
public bool NoBar { get; set; }
/// <summary>
/// Use UTF-8 encoding for output(default - ANSI)
///</summary>
public bool Utf8 { get; set; }
/// <summary>
/// Use UNICODE encoding for output
///</summary>
public bool Unicode { get; set; }
/// <summary>
/// Suppress IL assembler code output
///</summary>
public bool NoIL { get; set; }
/// <summary>
/// Use forward class declaration
///</summary>
public bool Forward { get; set; }
/// <summary>
/// Output full list of types(to preserve type ordering in round-trip)
///</summary>
public bool TypeList { get; set; }
/// <summary>
/// Display.NET projection view if input is a.winmd file
///</summary>
public bool Project { get; set; }
/// <summary>
/// Include file headers information in the output
///</summary>
public bool Headers { get; set; }
/// <summary>
/// =<class>[::<method>[(< sig >)] Disassemble the specified item only
///</summary>
public string Item { get; set; }
/// <summary>
/// Include statistics on the image
///</summary>
public bool Stats { get; set; }
/// <summary>
/// Include list of classes defined in the module
///</summary>
public bool ClassList { get; set; }
/// <summary>
/// Combination of /HEADER,/BYTES,/STATS,/CLASSLIST,/TOKENS
///</summary>
public bool All { get; set; }
/// <summary>
/// Options for EXE,DLL,OBJ and LIB files:
/// /METADATA[=< specifier >] Show MetaData, where<specifier> is:
/// /MDHEADER Show MetaData header information and sizes.
/// /HEX Show more things in hex as well as words.
/// /CSV Show the record counts and heap sizes.
/// /UNREX Show unresolved externals.
/// /SCHEMA Show the MetaData header and schema information.
/// /RAW Show the raw MetaData tables.
/// /HEAPS Show the raw heaps.
/// /VALIDATE Validate the consistency of the metadata.
/// </summary>
public string Metadata { get; set; }
/// <summary>
/// Options for LIB files only:
/// /OBJECTFILE=< obj_file_name > Show MetaData of a single object file in library
/// </summary>
public string ObjectFile { get; set; }
public override bool Execute()
{
try
{
string commandLine = "/OUT=" + Out;
if (Html) commandLine += " /HTML";
if (Rtf) commandLine += " /RTF";
if (Bytes) commandLine += " /BYTES";
if (RawEH) commandLine += " /RAWEH";
if (Tokens) commandLine += " /TOKENS";
if (Source) commandLine += " /SOURCE";
if (LineNum) commandLine += " /LINENUM";
if (Visibility != null && Visibility.Trim() != string.Empty) commandLine += " /VISIBILITY=" + Visibility;
if (PubOnly) commandLine += " /PUBONLY";
if (QuoteAllNames) commandLine += " /QUOTEALLNAMES";
if (NoCA) commandLine += " /NOCA";
if (CAVerbal) commandLine += " /CAVERBAL";
if (NoBar) commandLine += " /NOBAR";
if (Utf8) commandLine += " /UTF8";
if (Unicode) commandLine += " /UNICODE";
if (NoIL) commandLine += " /NOIL";
if (Forward) commandLine += " /FORWARD";
if (TypeList) commandLine += " /TYPELIST";
if (Headers) commandLine += " /HEADERS";
if (Item != null && Item.Trim() != string.Empty) commandLine += " /ITEM=" + Item;
if (Stats) commandLine += " /STATS";
if (ClassList) commandLine += " /CLASSLIST";
if (All) commandLine += " /ALL";
if (Metadata != null && Metadata.Trim() != string.Empty) commandLine += " /METADATA=" + Metadata;
if (ObjectFile != null && ObjectFile.Trim() != string.Empty) commandLine += " /OBJECTFILE=" + ObjectFile;
ProcessStartInfo startInfo = new ProcessStartInfo(ILDAsm);
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = Assembly + " " + commandLine;
Log.LogMessage("Starting process: " + startInfo.FileName + " " + startInfo.Arguments);
Process.Start(startInfo).WaitForExit();
return true;
}
catch (Exception e)
{
Log.LogError(e.ToString() + e.StackTrace);
return false;
}
}
}
}

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

@ -0,0 +1,59 @@
.class private auto ansi '<Module>'
{
.method private hidebysig specialname rtspecialname static void .cctor () cil managed
{
// Code size 76 (0x4c)
.maxstack 3
.locals init (class [mscorlib]System.Type V_0, bool V_1, class [mscorlib]System.Reflection.MethodInfo V_2, bool V_3)
IL_0000: nop
IL_0001: call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::GetExecutingAssembly()
IL_0006: ldstr "ModuleInitializer"
IL_000b: callvirt instance class [mscorlib]System.Type [mscorlib]System.Reflection.Assembly::GetType(string)
IL_0010: stloc.0
IL_0011: ldloc.0
IL_0012: ldnull
IL_0013: call bool [mscorlib]System.Type::op_Inequality(class [mscorlib]System.Type, class [mscorlib]System.Type)
IL_0018: stloc.1
IL_0019: ldloc.1
IL_001a: brfalse.s IL_004b
IL_001c: nop
IL_001d: ldloc.0
IL_001e: ldstr "Initialize"
IL_0023: ldc.i4.s 24
IL_0025: callvirt instance class [mscorlib]System.Reflection.MethodInfo [mscorlib]System.Type::GetMethod(string, valuetype [mscorlib]System.Reflection.BindingFlags)
IL_002a: stloc.2
IL_002b: ldloc.2
IL_002c: ldnull
IL_002d: call bool [mscorlib]System.Reflection.MethodInfo::op_Inequality(class [mscorlib]System.Reflection.MethodInfo, class [mscorlib]System.Reflection.MethodInfo)
IL_0032: stloc.3
IL_0033: ldloc.3
IL_0034: brfalse.s IL_004a
IL_0036: nop
.try
{
IL_0037: nop
IL_0038: ldloc.2
IL_0039: ldnull
IL_003a: ldnull
IL_003b: callvirt instance object [mscorlib]System.Reflection.MethodBase::Invoke(object, object[])
IL_0040: pop
IL_0041: nop
IL_0042: leave.s IL_0049
} // end .try
catch [mscorlib]System.Exception
{
IL_0044: pop
IL_0045: nop
IL_0046: nop
IL_0047: leave.s IL_0049
} // end handler
IL_0049: nop
IL_004a: nop
IL_004b: ret
}
}

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

@ -0,0 +1,5 @@
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 4:0:0:0
};

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

@ -15,7 +15,7 @@
<!-- This repo builds a transport package - we don't ship from here -->
<IsShippingPackage>false</IsShippingPackage>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright Condition="'$(CopyrightNetFoundation)' != ''">$(CopyrightNetFoundation)</Copyright>
@ -25,7 +25,7 @@
<PropertyGroup>
<GitHubTransportPackageName>Microsoft.DotNet.Wpf.GitHub</GitHubTransportPackageName>
<DncEngTransportPackageName>Microsoft.DotNet.Wpf.DncEng</DncEngTransportPackageName>
<!-- When ready to go live, remove .private suffix -->
<WindowsDesktopSdkPackageName>Microsoft.NET.Sdk.WindowsDesktop</WindowsDesktopSdkPackageName>
</PropertyGroup>

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

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
internal static class ModuleInitializer
{
/// <summary>
/// DirectWriteForwarder has a module constructor that implements
/// the setting of the default DPI awareness for the process.
/// We need to load DirectWriteForwarder the instant PresentationCore
/// loads in order to ensure that this is set before any DPI sensitive
/// operations are carried out. To do this, we simply call LoadDwrite
/// as the module constructor for DirectWriteForwarder would do this anyway.
/// </summary>
public static void Initialize()
{
MS.Internal.NativeWPFDLLLoader.LoadDwrite();
}
}

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

@ -9,6 +9,7 @@
<GenerateResourcesSRNamespace>MS.Internal.PresentationCore</GenerateResourcesSRNamespace>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<Platforms>AnyCPU;x64</Platforms>
<InjectModuleInitializer>true</InjectModuleInitializer>
</PropertyGroup>
<PropertyGroup>
@ -96,6 +97,7 @@
<Compile Include="$(WpfSharedDir)\Telemetry\Managed\TelemetryEventSource.cs" />
<Compile Include="$(WpfSharedDir)\Telemetry\Managed\TraceLoggingProvider.cs" />
<Compile Include="$(WpfSharedDir)\Telemetry\Managed\TraceLoggers\XpsOMPrintingTraceLogger.cs" />
<Compile Include="ModuleInitializer.cs" />
<Compile Include="otherassemblyattrs.cs" />
<Compile Include="SR.cs" />
<Compile Include="MS\Internal\AnimatedTypeHelpers.cs" />