diff --git a/src/Build.OM.UnitTests/NugetRestoreTests.cs b/src/Build.OM.UnitTests/NugetRestoreTests.cs index 1ee286b..f13f95a 100644 --- a/src/Build.OM.UnitTests/NugetRestoreTests.cs +++ b/src/Build.OM.UnitTests/NugetRestoreTests.cs @@ -23,7 +23,7 @@ public NugetRestoreTests(ITestOutputHelper output) // NuGet version 4.1.0 was somewhat arbitrarily chosen. 3.5 breaks with an unrelated error, and 4.8.2 does not fail when a new dependency is introduced. This is a safe middle point. #if !DEBUG [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp)] - [Fact] + [Fact(Skip = "IeXod. L-157")] public void TestOldNuget() { string IeXodPath = BuildEnvironmentHelper.Instance.IeXodBinPath; diff --git a/src/Build.UnitTests/BackEnd/BuildEventArgTransportSink_Tests.cs b/src/Build.UnitTests/BackEnd/BuildEventArgTransportSink_Tests.cs index 6bc4736..e5b7a97 100644 --- a/src/Build.UnitTests/BackEnd/BuildEventArgTransportSink_Tests.cs +++ b/src/Build.UnitTests/BackEnd/BuildEventArgTransportSink_Tests.cs @@ -124,7 +124,7 @@ void TransportDelegate(INodePacket packet) /// /// Make sure shutdown will correctly null out the send data delegate /// - [Fact] + [Fact(Skip = "IeXod. L-157")] [Trait("Category", "mono-osx-failing")] [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp, "https://github.com/Microsoft/msbuild/issues/282")] public void TestShutDown() diff --git a/src/Build.UnitTests/Evaluation/Expander_Tests.cs b/src/Build.UnitTests/Evaluation/Expander_Tests.cs index 0599e67..38cfe65 100644 --- a/src/Build.UnitTests/Evaluation/Expander_Tests.cs +++ b/src/Build.UnitTests/Evaluation/Expander_Tests.cs @@ -1818,7 +1818,7 @@ public void TestItemSpecModiferEscaping() [Trait("Category", "mono-osx-failing")] public void TestGetPathToReferenceAssembliesAsFunction() { - if (ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies(TargetDotNetFrameworkVersion.Version45) == null) + if (ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies(TargetDotNetFrameworkVersion.Version48) == null) { // if there aren't any reference assemblies installed on the machine in the first place, of course // we're not going to find them. :) @@ -1830,7 +1830,7 @@ public void TestGetPathToReferenceAssembliesAsFunction() .NETFramework - v4.5 + v4.8 $(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion) diff --git a/src/Build/IeXod.csproj b/src/Build/IeXod.csproj index 3785baf..941dd5a 100644 --- a/src/Build/IeXod.csproj +++ b/src/Build/IeXod.csproj @@ -37,6 +37,15 @@ PreserveNewest + + + + + PreserveNewest + + + PreserveNewest + @@ -45,7 +54,7 @@ - + diff --git a/src/DotNet.Sdk/IeXod.MSBSdkResolver/Interop.cs b/src/DotNet.Sdk/IeXod.MSBSdkResolver/Interop.cs index 76ce109..ac5d98a 100644 --- a/src/DotNet.Sdk/IeXod.MSBSdkResolver/Interop.cs +++ b/src/DotNet.Sdk/IeXod.MSBSdkResolver/Interop.cs @@ -6,7 +6,10 @@ using System; using System.IO; using System.Runtime.InteropServices; -using System.Text; +using net.r_eg.Conari; +using net.r_eg.Conari.Types; +using static net.r_eg.Conari.Static.Members; +using static net.r_eg.IeXod.Shared.FileSystem.WindowsNative; namespace net.r_eg.IeXod { @@ -14,14 +17,26 @@ internal static partial class Interop { internal static readonly bool RunningOnWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + // FIXME: original hostfxr preload does not work for netcoreapp targets. Instead we apply Conari using its runtime features; + // Fix or refactor legacy code to its nromal use + + private static readonly dynamic l; + static Interop() { + l = new ConariX(Path.Combine(Path.GetDirectoryName(typeof(Interop).Assembly.Location), Is64bit ? "x64" : "x86", "hostfxr")); + +#if IEXOD_SDKRSLV_INTEROP_LEGACY + if (RunningOnWindows) { PreloadWindowsLibrary("hostfxr.dll"); } +#endif } +#if IEXOD_SDKRSLV_INTEROP_LEGACY + // MSBuild SDK resolvers are required to be AnyCPU, but we have a native dependency and .NETFramework does not // have a built-in facility for dynamically loading user native dlls for the appropriate platform. We therefore // preload the version with the correct architecture (from a corresponding sub-folder relative to us) on static @@ -42,6 +57,7 @@ private static void PreloadWindowsLibrary(string dllFileName) [DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] private static extern IntPtr LoadLibraryExW(string lpFileName, IntPtr hFile, int dwFlags); +#endif [Flags] internal enum hostfxr_resolve_sdk2_flags_t : int @@ -57,6 +73,39 @@ internal enum hostfxr_resolve_sdk2_result_key_t : int internal static class Windows { + internal delegate void hostfxr_resolve_sdk2_result_fn + ( + hostfxr_resolve_sdk2_result_key_t key, + [MarshalAs(UnmanagedType.LPWStr)] string value + ); + + internal static int hostfxr_resolve_sdk2 + ( + string exe_dir, string working_dir, hostfxr_resolve_sdk2_flags_t flags, hostfxr_resolve_sdk2_result_fn result + ) + { // FIXME: Conari 1.5 supports automatic marshaling and normally we don't need new NativeString here at all; + // but only Xunit host + IeXod keeps strange behaviour until WCharPtr. Need to review. L-161 + using NativeString nExeDir = new(exe_dir); + using NativeString nWDir = new(working_dir); + + return l.hostfxr_resolve_sdk2(nExeDir, nWDir, flags, new hostfxr_resolve_sdk2_result_fn(result)); + } + + internal static int hostfxr_get_available_sdks(string exe_dir, hostfxr_get_available_sdks_result_fn result) + { + using NativeString nExeDir = new(exe_dir); // FIXME: ^ + return l.hostfxr_get_available_sdks(nExeDir, new hostfxr_get_available_sdks_result_fn(result)); + } + + internal delegate void hostfxr_get_available_sdks_result_fn + ( + int sdk_count, + [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0)] string[] sdk_dirs + ); + + +#if IEXOD_SDKRSLV_INTEROP_LEGACY + private const CharSet UTF16 = CharSet.Unicode; [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF16)] @@ -81,6 +130,8 @@ internal delegate void hostfxr_get_available_sdks_result_fn( internal static extern int hostfxr_get_available_sdks( string exe_dir, hostfxr_get_available_sdks_result_fn result); +#endif + } internal static class Unix diff --git a/src/DotNet.Sdk/IeXod.MSBSdkResolver/build.proj b/src/DotNet.Sdk/IeXod.MSBSdkResolver/build.proj index 672b0cc..abf01ea 100644 --- a/src/DotNet.Sdk/IeXod.MSBSdkResolver/build.proj +++ b/src/DotNet.Sdk/IeXod.MSBSdkResolver/build.proj @@ -5,7 +5,7 @@ win-x86;win-x64 MSBSdkResolver - true + true @@ -17,7 +17,7 @@ - + x86/hostfxr.dll diff --git a/src/Tasks.UnitTests/GetReferencePaths_Tests.cs b/src/Tasks.UnitTests/GetReferencePaths_Tests.cs index 0c429fc..11e98e1 100644 --- a/src/Tasks.UnitTests/GetReferencePaths_Tests.cs +++ b/src/Tasks.UnitTests/GetReferencePaths_Tests.cs @@ -28,7 +28,7 @@ sealed public class GetReferenceAssmeblyPath_Tests [Fact] public void TestGeneralFrameworkMonikerGood() { - string targetFrameworkMoniker = ".NetFramework, Version=v4.5"; + string targetFrameworkMoniker = ".NetFramework, Version=v4.8"; MockEngine engine = new MockEngine(); GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths(); getReferencePaths.BuildEngine = engine; diff --git a/src/Utilities.UnitTests/ToolLocationHelper_Tests.cs b/src/Utilities.UnitTests/ToolLocationHelper_Tests.cs index a1830ed..4cc611b 100644 --- a/src/Utilities.UnitTests/ToolLocationHelper_Tests.cs +++ b/src/Utilities.UnitTests/ToolLocationHelper_Tests.cs @@ -1967,17 +1967,17 @@ public void GetPathToReferenceAssembliesDefaultLocationNullFrameworkName() /// [Fact] [Trait("Category", "mono-osx-failing")] - public void GetPathToReferenceAssembliesDefaultLocation45() + public void GetPathToReferenceAssembliesDefaultLocation48() { FrameworkNameVersioning frameworkName = null; IList directories = null; - if (ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies(TargetDotNetFrameworkVersion.Version45) != null) + if (ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies(TargetDotNetFrameworkVersion.Version48) != null) { - frameworkName = new FrameworkNameVersioning(".NETFramework", new Version("4.5")); + frameworkName = new FrameworkNameVersioning(".NETFramework", new Version("4.8")); directories = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkName); directories.Count.ShouldBe(1); // "Expected the method to return one path." - string referenceAssemblyPath = ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies(TargetDotNetFrameworkVersion.Version45); + string referenceAssemblyPath = ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies(TargetDotNetFrameworkVersion.Version48); directories[0].ShouldBe(referenceAssemblyPath, StringCompareShould.IgnoreCase); } // else diff --git a/src/common.props b/src/common.props index 94029f5..b19305e 100644 --- a/src/common.props +++ b/src/common.props @@ -18,6 +18,7 @@ $(MSBuildThisFileDirectory)com.github.3F.snk true false + true diff --git a/src/versions.props b/src/versions.props index a17988b..516b14c 100644 --- a/src/versions.props +++ b/src/versions.props @@ -7,6 +7,7 @@ + 1.5.0 1.0.0-beta.19253.1 1.7.1 4.11.1