From ee329dd681c553c0ea582acc67718f63247116c9 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 28 Mar 2018 10:06:56 -0700 Subject: [PATCH] Add deps file RH injection. Do not build targets if assembly exists to prevent test errors (#735) This reverts commit 847ab71209044287868d516a2b939e42ddda5577. --- IISIntegration.sln | 15 ++++ build/dependencies.props | 3 + build/testsite.props | 22 ++++++ .../NativeIISSample/NativeIISSample.csproj | 1 - test/TestTasks/InjectRequestHandler.cs | 74 +++++++++++++++++++ test/TestTasks/TestTasks.csproj | 13 ++++ 6 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 test/TestTasks/InjectRequestHandler.cs create mode 100644 test/TestTasks/TestTasks.csproj diff --git a/IISIntegration.sln b/IISIntegration.sln index 4086f09be5..3508392e9d 100644 --- a/IISIntegration.sln +++ b/IISIntegration.sln @@ -74,6 +74,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AspNetCoreModuleTests", "te EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ANCMStressTestApp", "test\ANCMStressTestApp\ANCMStressTestApp.csproj", "{13FD8F12-FFBE-4D01-B4AC-444F2994B04F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestTasks", "test\TestTasks\TestTasks.csproj", "{064D860B-4D7C-4B1D-918F-E020F1B99E2A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -242,6 +244,18 @@ Global {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x64.Build.0 = Release|Any CPU {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x86.ActiveCfg = Release|Any CPU {13FD8F12-FFBE-4D01-B4AC-444F2994B04F}.Release|x86.Build.0 = Release|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x64.ActiveCfg = Debug|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x64.Build.0 = Debug|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x86.ActiveCfg = Debug|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Debug|x86.Build.0 = Debug|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|Any CPU.Build.0 = Release|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x64.ActiveCfg = Release|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x64.Build.0 = Release|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.ActiveCfg = Release|Any CPU + {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -261,6 +275,7 @@ Global {46A8612B-418B-4D70-B3A7-A21DD0627473} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {0692D963-DB10-4387-B3EA-460FBB9BD9A3} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {13FD8F12-FFBE-4D01-B4AC-444F2994B04F} = {EF30B533-D715-421A-92B7-92FEF460AC9C} + {064D860B-4D7C-4B1D-918F-E020F1B99E2A} = {EF30B533-D715-421A-92B7-92FEF460AC9C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DB4F868D-E1AE-4FD7-9333-69FA15B268C5} diff --git a/build/dependencies.props b/build/dependencies.props index 07933c585a..a4f334fe47 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -17,6 +17,8 @@ 2.1.0-preview2-30431 2.1.0-preview2-30431 2.1.0-preview2-30431 + 15.6.82 + 15.6.82 2.1.0-preview2-30431 2.1.0-preview2-30431 2.1.0-preview2-30431 @@ -41,6 +43,7 @@ 4.5.0-preview2-26313-01 4.5.0-preview2-26313-01 4.5.0-preview2-26313-01 + 9.0.1 2.3.1 2.4.0-beta.1.build3945 diff --git a/build/testsite.props b/build/testsite.props index 549556790f..f706a70a44 100644 --- a/build/testsite.props +++ b/build/testsite.props @@ -34,7 +34,29 @@ -h "$(IISAppHostConfig)" $(NativePlatform)\aspnetcore.dll + $(NativePlatform)\aspnetcorerh.dll $(userprofile)\.dotnet\$(NativePlatform)\dotnet.exe + + $(MSBuildThisFileDirectory)..\test\TestTasks\bin\$(Configuration)\netstandard2.0\TestTasks.dll + + + + + false + False + + + + + + + + + + + + + diff --git a/samples/NativeIISSample/NativeIISSample.csproj b/samples/NativeIISSample/NativeIISSample.csproj index d35016b658..d9bf22ba16 100644 --- a/samples/NativeIISSample/NativeIISSample.csproj +++ b/samples/NativeIISSample/NativeIISSample.csproj @@ -17,5 +17,4 @@ inprocess - diff --git a/test/TestTasks/InjectRequestHandler.cs b/test/TestTasks/InjectRequestHandler.cs new file mode 100644 index 0000000000..a97d5718a4 --- /dev/null +++ b/test/TestTasks/InjectRequestHandler.cs @@ -0,0 +1,74 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Linq; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace TestTasks +{ + public class InjectRequestHandler : Task + { + [Required] + public string DepsFile { get; set; } + + [Required] + public string Rid { get; set; } + + [Required] + public string LibraryLocation { get; set; } + + public override bool Execute() + { + InjectNativeLibrary(DepsFile); + + // Parse input + return true; + } + + private void InjectNativeLibrary(string depsFile) + { + JToken deps; + using (var file = File.OpenText(depsFile)) + using (JsonTextReader reader = new JsonTextReader(file)) + { + deps = JObject.ReadFrom(reader); + } + + var libraryName = "ANCMRH/1.0"; + var libraries = (JObject)deps["libraries"]; + + var target = (JObject)((JObject)deps["targets"]).Properties().First().Value; + var targetLibrary = target.Properties().FirstOrDefault(p => p.Name == libraryName); + targetLibrary?.Remove(); + targetLibrary = + new JProperty(libraryName, new JObject( + new JProperty("runtimeTargets", new JObject( + new JProperty(LibraryLocation.Replace('\\', '/'), new JObject( + new JProperty("rid", Rid), + new JProperty("assetType", "native") + )))))); + target.AddFirst(targetLibrary); + + var library = libraries.Properties().FirstOrDefault(p => p.Name == libraryName); + library?.Remove(); + library = + new JProperty(libraryName, new JObject( + new JProperty("type", "package"), + new JProperty("serviceable", true), + new JProperty("sha512", ""), + new JProperty("path", libraryName), + new JProperty("hashPath", ""))); + libraries.AddFirst(library); + + using (var file = File.CreateText(depsFile)) + using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) + { + deps.WriteTo(writer); + } + } + } +} diff --git a/test/TestTasks/TestTasks.csproj b/test/TestTasks/TestTasks.csproj new file mode 100644 index 0000000000..24a26e6253 --- /dev/null +++ b/test/TestTasks/TestTasks.csproj @@ -0,0 +1,13 @@ + + + + netstandard2.0 + + + + + + + + +