From 122974c34ed17db685d9623635e989080d0ba644 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Mon, 6 Feb 2017 14:03:27 -0800 Subject: [PATCH 01/20] Initial test asset --- .../AppWithLibraryAndRid/App/App.csproj | 14 ++++++++++++++ .../AppWithLibraryAndRid/App/Program.cs | 12 ++++++++++++ .../AppWithLibraryAndRid/Library/Class1.cs | 8 ++++++++ .../AppWithLibraryAndRid/Library/Library.csproj | 7 +++++++ .../LibraryWithoutRid/Class1.cs | 8 ++++++++ .../LibraryWithoutRid/LibraryWithoutRid.csproj | 8 ++++++++ 6 files changed, 57 insertions(+) create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/Library/Class1.cs create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/Class1.cs create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj new file mode 100755 index 000000000000..5a038f97ec78 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp1.0 + osx.10.11-x64 + + + + + + + + diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs new file mode 100755 index 000000000000..be4278310c20 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace App +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Class1.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Class1.cs new file mode 100755 index 000000000000..9bc1568ad6f0 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace Library +{ + public class Class1 + { + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj new file mode 100755 index 000000000000..b290d67fb724 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj @@ -0,0 +1,7 @@ + + + + netstandard1.4 + + + diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/Class1.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/Class1.cs new file mode 100755 index 000000000000..e53a5704da3b --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace LibraryWithoutRid +{ + public class Class1 + { + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj new file mode 100755 index 000000000000..3c29c8e234cc --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj @@ -0,0 +1,8 @@ + + + + netstandard1.4 + osx.10.11-x64 + + + From 6e4147e96f6523bcd4ac63151b76c35aa0570483 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Mon, 6 Feb 2017 16:13:02 -0800 Subject: [PATCH 02/20] Red test --- ...atWeWantToBuildASelfContainedAppWithRid.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs new file mode 100644 index 000000000000..7cfa8528ed4d --- /dev/null +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs @@ -0,0 +1,56 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using FluentAssertions; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.InternalAbstractions; +using Microsoft.NET.TestFramework; +using Microsoft.NET.TestFramework.Commands; +using Microsoft.NET.TestFramework.Assertions; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Xml.Linq; +using Xunit; +using static Microsoft.NET.TestFramework.Commands.MSBuildTest; + +namespace Microsoft.NET.Build.Tests +{ + public class GivenThatWeWantToBuildASelfContainedAppWithRid : SdkTest + { + [Fact] + public void It_builds_a_runnable_output() + { + var runtimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier(); + var testAsset = _testAssetsManager + .CopyTestAsset("AppWithLibraryAndRid") + .WithSource(); + + var projectPath = Path.Combine(testAsset.TestRoot, "App"); + + var restoreCommand = new RestoreCommand(Stage0MSBuild, projectPath, "App.csproj"); + restoreCommand + .Execute() + .Should() + .Pass(); + + var buildCommand = new BuildCommand(Stage0MSBuild, projectPath); + + buildCommand + .Execute($"/p:RuntimeIdentifier={runtimeIdentifier}") + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.0", runtimeIdentifier: runtimeIdentifier); + var selfContainedExecutable = $"HelloWorld{Constants.ExeSuffix}"; + + Command.Create(Path.Combine(outputDirectory.FullName, selfContainedExecutable), new string[] { }) + .CaptureStdOut() + .Execute() + .Should() + .Pass() + .And + .HaveStdOutContaining("Hello World!"); + } + } +} From bc0ed40cb4b5ab3e95cedcd83c00788fc161b9d6 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Mon, 6 Feb 2017 20:19:39 -0800 Subject: [PATCH 03/20] Enable building Portable P2P dependencies of RID-specific projects --- .../AppWithLibraryAndRid/App/Program.cs | 8 ++++++- .../AppWithLibraryAndRid/Library/Class1.cs | 8 ------- .../Library/Library.csproj | 13 +++++++---- .../Library/NativeCode.cs | 23 +++++++++++++++++++ .../Library/NativeMethods.cs | 12 ++++++++++ .../LibraryWithoutRid/Class1.cs | 8 ------- .../LibraryWithoutRid.csproj | 1 - .../LibraryWithoutRid/PortableCode.cs | 12 ++++++++++ .../build/Microsoft.NET.Sdk.Common.targets | 6 ++++- ...atWeWantToBuildASelfContainedAppWithRid.cs | 9 +++----- 10 files changed, 71 insertions(+), 29 deletions(-) delete mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/Library/Class1.cs create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeCode.cs create mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeMethods.cs delete mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/Class1.cs create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/PortableCode.cs diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs index be4278310c20..5706ad400015 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs @@ -6,7 +6,13 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + var valueFromNativeDependency = Library.NativeCode.InvokeNativeCodeAndReturnAString(); + + var compileTimeRid = Library.NativeCode.GetRidStoredInAssemblyDescriptionAttribute(); + + var valueFromPortableDependency = LibraryWithoutRid.PortableClass.GetHelloWorld(); + + Console.WriteLine($"{valueFromNativeDependency} {compileTimeRid} {valueFromPortableDependency}"); } } } diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Class1.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Class1.cs deleted file mode 100755 index 9bc1568ad6f0..000000000000 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Library -{ - public class Class1 - { - } -} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj index b290d67fb724..48b1c7b089d7 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj @@ -1,7 +1,12 @@ - - + netstandard1.4 + osx.10.11-x64 + '$(RuntimeIdentifier)' - - + + + 3.13.0 + + + \ No newline at end of file diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeCode.cs new file mode 100755 index 000000000000..99782d08c83b --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeCode.cs @@ -0,0 +1,23 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace Library +{ + public class NativeCode + { + public static string InvokeNativeCodeAndReturnAString() + { + return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); + } + + public static string GetRidStoredInAssemblyDescriptionAttribute() + { + return typeof(NativeCode) + .GetTypeInfo() + .Assembly + .GetCustomAttribute() + ?.Description; + } + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeMethods.cs new file mode 100644 index 000000000000..bf80ba516334 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeMethods.cs @@ -0,0 +1,12 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Library +{ + public static class NativeMethod + { + [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_libversion(); + } +} \ No newline at end of file diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/Class1.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/Class1.cs deleted file mode 100755 index e53a5704da3b..000000000000 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace LibraryWithoutRid -{ - public class Class1 - { - } -} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj index 3c29c8e234cc..b290d67fb724 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj @@ -2,7 +2,6 @@ netstandard1.4 - osx.10.11-x64 diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/PortableCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/PortableCode.cs new file mode 100755 index 000000000000..d90d7b5ee7e0 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/PortableCode.cs @@ -0,0 +1,12 @@ +using System; + +namespace LibraryWithoutRid +{ + public class PortableClass + { + public static string GetHelloWorld() + { + return "Hello World"; + } + } +} diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets index c751ce9da341..5dd160dc635f 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets @@ -51,9 +51,13 @@ Copyright (c) .NET Foundation. All rights reserved. with the referencing project's target framework. ============================================================ --> - + + + $(ReferringRuntimeIdentifier) + + <_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true $(TargetFramework) diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs index 7cfa8528ed4d..438c147b5c12 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs @@ -8,9 +8,6 @@ using Microsoft.NET.TestFramework.Commands; using Microsoft.NET.TestFramework.Assertions; using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Xml.Linq; using Xunit; using static Microsoft.NET.TestFramework.Commands.MSBuildTest; @@ -41,8 +38,8 @@ public void It_builds_a_runnable_output() .Should() .Pass(); - var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.0", runtimeIdentifier: runtimeIdentifier); - var selfContainedExecutable = $"HelloWorld{Constants.ExeSuffix}"; + var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.0"); + var selfContainedExecutable = $"App{Constants.ExeSuffix}"; Command.Create(Path.Combine(outputDirectory.FullName, selfContainedExecutable), new string[] { }) .CaptureStdOut() @@ -50,7 +47,7 @@ public void It_builds_a_runnable_output() .Should() .Pass() .And - .HaveStdOutContaining("Hello World!"); + .HaveStdOutContaining($"3.13.0 '{runtimeIdentifier}' Hello World"); } } } From bf2aec9d6154f44d115c037af4f9495c96996177 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Mon, 6 Feb 2017 23:48:40 -0800 Subject: [PATCH 04/20] PR feedback --- .../AppWithLibraryAndRid/App/App.csproj | 3 ++- .../AppWithLibraryAndRid/App/Program.cs | 16 +++++++++---- .../LibraryWithRid/LibraryWithRid.csproj | 14 +++++++++++ .../{Library => LibraryWithRid}/NativeCode.cs | 2 +- .../NativeMethods.cs | 5 ++-- .../LibraryWithRids.csproj} | 2 +- .../LibraryWithRids/NativeCode.cs | 23 +++++++++++++++++++ .../LibraryWithRids/NativeMethods.cs | 11 +++++++++ .../build/Microsoft.NET.Sdk.Common.targets | 4 ++-- ...atWeWantToBuildASelfContainedAppWithRid.cs | 10 ++++---- 10 files changed, 73 insertions(+), 17 deletions(-) create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LibraryWithRid.csproj rename TestAssets/TestProjects/AppWithLibraryAndRid/{Library => LibraryWithRid}/NativeCode.cs (95%) rename TestAssets/TestProjects/AppWithLibraryAndRid/{Library => LibraryWithRid}/NativeMethods.cs (89%) rename TestAssets/TestProjects/AppWithLibraryAndRid/{Library/Library.csproj => LibraryWithRids/LibraryWithRids.csproj} (97%) create mode 100755 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs create mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj index 5a038f97ec78..0fe412c26ef5 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj @@ -7,7 +7,8 @@ - + + diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs index 5706ad400015..32764e35d63a 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs @@ -6,13 +6,21 @@ class Program { static void Main(string[] args) { - var valueFromNativeDependency = Library.NativeCode.InvokeNativeCodeAndReturnAString(); + var libraryWithRidNativeOutput = LibraryWithRid.NativeCode.InvokeNativeCodeAndReturnAString(); - var compileTimeRid = Library.NativeCode.GetRidStoredInAssemblyDescriptionAttribute(); + var libraryWithRidsNativeOutput = LibraryWithRid.NativeCode.InvokeNativeCodeAndReturnAString(); - var valueFromPortableDependency = LibraryWithoutRid.PortableClass.GetHelloWorld(); + var libraryWithRidCompileTimeRid = LibraryWithRid.NativeCode.GetRidStoredInAssemblyDescriptionAttribute(); - Console.WriteLine($"{valueFromNativeDependency} {compileTimeRid} {valueFromPortableDependency}"); + var libraryWithRidsCompileTimeRid = LibraryWithRids.NativeCode.GetRidStoredInAssemblyDescriptionAttribute(); + + var libraryWithRidStatus = $"{libraryWithRidNativeOutput} {libraryWithRidCompileTimeRid}"; + + var libraryWithRidsStatus = $"{libraryWithRidsNativeOutput} {libraryWithRidsCompileTimeRid}"; + + var portableLibraryStatus = LibraryWithoutRid.PortableClass.GetHelloWorld(); + + Console.WriteLine($"{libraryWithRidStatus} {libraryWithRidsStatus} {portableLibraryStatus}"); } } } diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LibraryWithRid.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LibraryWithRid.csproj new file mode 100755 index 000000000000..c7060fc094cb --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LibraryWithRid.csproj @@ -0,0 +1,14 @@ + + + netstandard1.4 + $(TestRuntimeIdentifier) + + + '$(RuntimeIdentifier)' + + + + 3.13.0 + + + diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs similarity index 95% rename from TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeCode.cs rename to TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs index 99782d08c83b..dff1f93b0da7 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeCode.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs @@ -2,7 +2,7 @@ using System.Reflection; using System.Runtime.InteropServices; -namespace Library +namespace LibraryWithRid { public class NativeCode { diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs similarity index 89% rename from TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeMethods.cs rename to TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs index bf80ba516334..4add46cf4650 100644 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/NativeMethods.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs @@ -1,12 +1,11 @@ - using System; using System.Runtime.InteropServices; -namespace Library +namespace LibraryWithRid { public static class NativeMethod { [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr sqlite3_libversion(); } -} \ No newline at end of file +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj similarity index 97% rename from TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj rename to TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj index 48b1c7b089d7..203af10eda98 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/Library/Library.csproj +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj @@ -9,4 +9,4 @@ 3.13.0 - \ No newline at end of file + diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs new file mode 100755 index 000000000000..533d0a252243 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs @@ -0,0 +1,23 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace LibraryWithRids +{ + public class NativeCode + { + public static string InvokeNativeCodeAndReturnAString() + { + return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); + } + + public static string GetRidStoredInAssemblyDescriptionAttribute() + { + return typeof(NativeCode) + .GetTypeInfo() + .Assembly + .GetCustomAttribute() + ?.Description; + } + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs new file mode 100644 index 000000000000..5816f74a9abe --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibraryWithRids +{ + public static class NativeMethod + { + [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_libversion(); + } +} diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets index 5dd160dc635f..a374a39c0c4d 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets @@ -54,10 +54,10 @@ Copyright (c) .NET Foundation. All rights reserved. - + $(ReferringRuntimeIdentifier) - + <_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true $(TargetFramework) diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs index 438c147b5c12..8ab5f4199eb4 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs @@ -13,10 +13,10 @@ namespace Microsoft.NET.Build.Tests { - public class GivenThatWeWantToBuildASelfContainedAppWithRid : SdkTest + public class GivenThatWeWantToBuildASelfContainedAppWithLibrariesAndRid : SdkTest { [Fact] - public void It_builds_a_runnable_output() + public void It_builds_a_RID_specific_runnable_output() { var runtimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier(); var testAsset = _testAssetsManager @@ -27,14 +27,14 @@ public void It_builds_a_runnable_output() var restoreCommand = new RestoreCommand(Stage0MSBuild, projectPath, "App.csproj"); restoreCommand - .Execute() + .Execute($"/p:TestRuntimeIdentifier={runtimeIdentifier}") .Should() .Pass(); var buildCommand = new BuildCommand(Stage0MSBuild, projectPath); buildCommand - .Execute($"/p:RuntimeIdentifier={runtimeIdentifier}") + .Execute($"/p:RuntimeIdentifier={runtimeIdentifier}", $"/p:TestRuntimeIdentifier={runtimeIdentifier}") .Should() .Pass(); @@ -47,7 +47,7 @@ public void It_builds_a_runnable_output() .Should() .Pass() .And - .HaveStdOutContaining($"3.13.0 '{runtimeIdentifier}' Hello World"); + .HaveStdOutContaining($"3.13.0 '{runtimeIdentifier}' 3.13.0 '{runtimeIdentifier}' Hello World"); } } } From 7a3a4ce37f822a42469d7e081c9b0a1503aa4312 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 8 Feb 2017 13:33:48 -0800 Subject: [PATCH 05/20] Avoid RuntimeIdentifer override if ReferringRuntimeIdentifier == '' --- .../build/Microsoft.NET.Sdk.Common.targets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets index a374a39c0c4d..9e8a820c2c14 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets @@ -51,12 +51,13 @@ Copyright (c) .NET Foundation. All rights reserved. with the referencing project's target framework. ============================================================ --> - + $(ReferringRuntimeIdentifier) + ;RuntimeIdentifier=$(NearestRuntimeIdentifier) <_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true From ad9f19e8ef1bed8343e9c32a81c55bff9ac07f96 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 8 Feb 2017 14:18:09 -0800 Subject: [PATCH 06/20] Override Runtime Identifier IFF this proj portable & referring is not --- .../build/Microsoft.NET.Sdk.Common.targets | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets index 9e8a820c2c14..8b44daa9dc99 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets @@ -54,10 +54,8 @@ Copyright (c) .NET Foundation. All rights reserved. - - $(ReferringRuntimeIdentifier) - - ;RuntimeIdentifier=$(NearestRuntimeIdentifier) + + ;RuntimeIdentifier= <_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true From df90c6de4b008f57f60823a8b4cf09498fd131bc Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 10 Feb 2017 16:30:14 -0800 Subject: [PATCH 07/20] Detect Global RuntimeIdentifier --- .../build/Microsoft.NET.Sdk.props | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props index a46e4354d3b0..22e31f9c6e78 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props @@ -128,6 +128,19 @@ Copyright (c) .NET Foundation. All rights reserved. CurrentRuntime + + + $(RuntimeIdentifier) + __________ + + + $(GlobalRuntimeIdentifier) + + + + ;ReferringRuntimeIdentifier=$(GlobalRuntimeIdentifier) + + From 38383287ad515c0c12503a4970ced0c2e3e5c85f Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 10 Feb 2017 16:38:47 -0800 Subject: [PATCH 08/20] Comments. --- .../build/Microsoft.NET.Sdk.props | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props index 22e31f9c6e78..6e4697ef95e8 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props @@ -128,15 +128,23 @@ Copyright (c) .NET Foundation. All rights reserved. CurrentRuntime - + + $(RuntimeIdentifier) + __________ + + $(GlobalRuntimeIdentifier) + + + ;ReferringRuntimeIdentifier=$(GlobalRuntimeIdentifier) From 4b470364060f72f21134cdcfacfe7b1adfaa7cc2 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Tue, 14 Feb 2017 00:04:46 -0800 Subject: [PATCH 09/20] Account for Rainer's feedback. --- .../build/Microsoft.NET.Sdk.Common.targets | 7 ++++--- .../build/Microsoft.NET.Sdk.props | 21 ------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets index 8b44daa9dc99..4355cb4f8b70 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets @@ -51,12 +51,13 @@ Copyright (c) .NET Foundation. All rights reserved. with the referencing project's target framework. ============================================================ --> - + - ;RuntimeIdentifier= - + false + true + <_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true $(TargetFramework) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props index 6e4697ef95e8..a46e4354d3b0 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props @@ -128,27 +128,6 @@ Copyright (c) .NET Foundation. All rights reserved. CurrentRuntime - - - - $(RuntimeIdentifier) - - __________ - - - - - $(GlobalRuntimeIdentifier) - - - - - - - ;ReferringRuntimeIdentifier=$(GlobalRuntimeIdentifier) - - From d9d3d55cee024223e6370048015553beacf7e110 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Tue, 14 Feb 2017 00:13:48 -0800 Subject: [PATCH 10/20] Missing quote --- .vscode/launch.json | 23 +++++++++++++++++++ .vscode/tasks.json | 16 +++++++++++++ .../build/Microsoft.NET.Sdk.Common.targets | 4 ++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000000..d34cb56ec47f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}/TestAssets/TestProjects/AllResourcesInSatellite/bin/Debug/netcoreapp1.0/AllResourcesInSatellite.dll", + "args": [], + "cwd": "${workspaceRoot}", + "externalConsole": false, + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command.pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000000..302769a02de4 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "0.1.0", + "command": "dotnet", + "isShellCommand": true, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ + "${workspaceRoot}/TestAssets/TestProjects/AllResourcesInSatellite/AllResourcesInSatellite.csproj" + ], + "isBuildCommand": true, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets index 4355cb4f8b70..a6689989ab6e 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets @@ -56,8 +56,8 @@ Copyright (c) .NET Foundation. All rights reserved. false - true - + true + <_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true $(TargetFramework) From 98e2390126400a5c0858a202826daf0c93ee7286 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 16:00:48 -0800 Subject: [PATCH 11/20] Update CLI --- DotnetCLIVersion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DotnetCLIVersion.txt b/DotnetCLIVersion.txt index f2e359f0b18b..22921e54bcbc 100644 --- a/DotnetCLIVersion.txt +++ b/DotnetCLIVersion.txt @@ -1 +1 @@ -1.0.0-rc4-004771 \ No newline at end of file +1.0.0-rc4-004828 \ No newline at end of file From 78a0bd4b4e8673af16b6ce9d1b388e014d63a140 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 16:05:14 -0800 Subject: [PATCH 12/20] Remove accidentally added .vscode files --- .vscode/launch.json | 23 ----------------------- .vscode/tasks.json | 16 ---------------- 2 files changed, 39 deletions(-) delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index d34cb56ec47f..000000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceRoot}/TestAssets/TestProjects/AllResourcesInSatellite/bin/Debug/netcoreapp1.0/AllResourcesInSatellite.dll", - "args": [], - "cwd": "${workspaceRoot}", - "externalConsole": false, - "stopAtEntry": false, - "internalConsoleOptions": "openOnSessionStart" - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command.pickProcess}" - } - ] -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 302769a02de4..000000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "0.1.0", - "command": "dotnet", - "isShellCommand": true, - "args": [], - "tasks": [ - { - "taskName": "build", - "args": [ - "${workspaceRoot}/TestAssets/TestProjects/AllResourcesInSatellite/AllResourcesInSatellite.csproj" - ], - "isBuildCommand": true, - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file From 5996796bd8bf618c369c01c4b2ee37b31dfa69f1 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 16:06:26 -0800 Subject: [PATCH 13/20] add .vscode to .gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c6692c567b33..37ef0f552f5c 100644 --- a/.gitignore +++ b/.gitignore @@ -181,4 +181,7 @@ project.json.template # Ignore Generated project template files Project.csproj -Project.vbproj \ No newline at end of file +Project.vbproj + +# VS Code +.vscode/ From 13fc5ddad0047e411887b534c2e9882adeeb4c82 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 16:22:11 -0800 Subject: [PATCH 14/20] Add missing RIDs --- TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj index 0fe412c26ef5..65dc6d9782db 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj @@ -3,7 +3,7 @@ Exe netcoreapp1.0 - osx.10.11-x64 + osx.10.11-x64;ubuntu.14.04-x64;win10-x64 From 27381b7cbc36f00bcdd01862ec16ad384cb3da2d Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 16:26:39 -0800 Subject: [PATCH 15/20] PR feedback --- .../build/Microsoft.NET.Sdk.Common.targets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets index a6689989ab6e..1cdc34e1eca1 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets @@ -51,12 +51,12 @@ Copyright (c) .NET Foundation. All rights reserved. with the referencing project's target framework. ============================================================ --> - + - - false - true + + <_IsRidAgnostic>false + <_IsRidAgnostic Condition=" '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == '' ">true <_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true From ad428807dd6846a2fa7060c53275433edd7203b5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 16:31:04 -0800 Subject: [PATCH 16/20] Add missing RIDs to Lib --- .../AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj index 203af10eda98..e4cc0d3ae54c 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj @@ -1,7 +1,7 @@  netstandard1.4 - osx.10.11-x64 + osx.10.11-x64;ubuntu.14.04-x64;win10-x64 '$(RuntimeIdentifier)' From 4235a5726269676b492d6a60e6ca7c87de698a4f Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 17:15:43 -0800 Subject: [PATCH 17/20] RID-specific lib... --- .../LibraryWithRid/NativeCode.cs | 12 +++++++++++- .../LibraryWithRid/NativeMethods.cs | 6 ++++++ .../LibraryWithRids/NativeCode.cs | 12 +++++++++++- .../LibraryWithRids/NativeMethods.cs | 6 ++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs index dff1f93b0da7..bb4b7a672215 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs @@ -8,7 +8,17 @@ public class NativeCode { public static string InvokeNativeCodeAndReturnAString() { - return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); + switch(GetRidStoredInAssemblyDescriptionAttribute()) + { + case "ubuntu.14.04-x64": + return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); + case "osx.10.11-x64": + return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dylibversion()); + case "win10-x64": + return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dllversion()); + default: + return "Unexpected RID. Cannot find sqlite3."; + } } public static string GetRidStoredInAssemblyDescriptionAttribute() diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs index 4add46cf4650..b1b890f8cd2a 100644 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs @@ -7,5 +7,11 @@ public static class NativeMethod { [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr sqlite3_libversion(); + + [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_dylibversion(); + + [DllImport("sqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_dllversion(); } } diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs index 533d0a252243..5fdcfa47903a 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs @@ -8,7 +8,17 @@ public class NativeCode { public static string InvokeNativeCodeAndReturnAString() { - return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); + switch(GetRidStoredInAssemblyDescriptionAttribute()) + { + case "ubuntu.14.04-x64": + return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); + case "osx.10.11-x64": + return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dylibversion()); + case "win10-x64": + return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dllversion()); + default: + return "Unexpected RID. Cannot find sqlite3."; + } } public static string GetRidStoredInAssemblyDescriptionAttribute() diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs index 5816f74a9abe..4258a4ee533e 100644 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs @@ -7,5 +7,11 @@ public static class NativeMethod { [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr sqlite3_libversion(); + + [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_dylibversion(); + + [DllImport("sqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_dllversion(); } } From 46f63c550505a8b13e396401c4e790482bd8dea4 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 17:50:02 -0800 Subject: [PATCH 18/20] Fix switch conditions --- .../AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs | 6 +++--- .../AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs index bb4b7a672215..c14d9f637689 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs @@ -10,11 +10,11 @@ public static string InvokeNativeCodeAndReturnAString() { switch(GetRidStoredInAssemblyDescriptionAttribute()) { - case "ubuntu.14.04-x64": + case "'ubuntu.14.04-x64'": return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); - case "osx.10.11-x64": + case "'osx.10.11-x64'": return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dylibversion()); - case "win10-x64": + case "'win10-x64'": return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dllversion()); default: return "Unexpected RID. Cannot find sqlite3."; diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs index 5fdcfa47903a..ae135b16c756 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs @@ -10,11 +10,11 @@ public static string InvokeNativeCodeAndReturnAString() { switch(GetRidStoredInAssemblyDescriptionAttribute()) { - case "ubuntu.14.04-x64": + case "'ubuntu.14.04-x64'": return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); - case "osx.10.11-x64": + case "'osx.10.11-x64'": return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dylibversion()); - case "win10-x64": + case "'win10-x64'": return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dllversion()); default: return "Unexpected RID. Cannot find sqlite3."; From 62ad144c1d0654b409d5f18d412370154ec25144 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 18:09:13 -0800 Subject: [PATCH 19/20] Fix x-plat native invocation --- .../LibraryWithRid/LinuxNativeMethods.cs | 11 +++++++++++ .../LibraryWithRid/MacNativeMethods.cs | 11 +++++++++++ .../LibraryWithRid/NativeCode.cs | 6 +++--- .../LibraryWithRid/NativeMethods.cs | 17 ----------------- .../LibraryWithRid/WindowsNativeMethods.cs | 11 +++++++++++ .../LibraryWithRids/LinuxNativeMethods.cs | 11 +++++++++++ .../LibraryWithRids/MacNativeMethods.cs | 11 +++++++++++ .../LibraryWithRids/NativeCode.cs | 6 +++--- .../LibraryWithRids/NativeMethods.cs | 17 ----------------- .../LibraryWithRids/WindowsNativeMethods.cs | 11 +++++++++++ 10 files changed, 72 insertions(+), 40 deletions(-) create mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LinuxNativeMethods.cs create mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/MacNativeMethods.cs delete mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs create mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/WindowsNativeMethods.cs create mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LinuxNativeMethods.cs create mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/MacNativeMethods.cs delete mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs create mode 100644 TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/WindowsNativeMethods.cs diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LinuxNativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LinuxNativeMethods.cs new file mode 100644 index 000000000000..d9729d57ece6 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LinuxNativeMethods.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibraryWithRid +{ + public static class LinuxNativeMethods + { + [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_libversion(); + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/MacNativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/MacNativeMethods.cs new file mode 100644 index 000000000000..b26a077f20a0 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/MacNativeMethods.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibraryWithRid +{ + public static class MacNativeMethods + { + [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_libversion(); + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs index c14d9f637689..e5b4c89cafa4 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs @@ -11,11 +11,11 @@ public static string InvokeNativeCodeAndReturnAString() switch(GetRidStoredInAssemblyDescriptionAttribute()) { case "'ubuntu.14.04-x64'": - return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); + return Marshal.PtrToStringAnsi(LinuxNativeMethods.sqlite3_libversion()); case "'osx.10.11-x64'": - return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dylibversion()); + return Marshal.PtrToStringAnsi(MacNativeMethods.sqlite3_libversion()); case "'win10-x64'": - return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dllversion()); + return Marshal.PtrToStringAnsi(WindowsNativeMethods.sqlite3_libversion()); default: return "Unexpected RID. Cannot find sqlite3."; } diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs deleted file mode 100644 index b1b890f8cd2a..000000000000 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeMethods.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace LibraryWithRid -{ - public static class NativeMethod - { - [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr sqlite3_libversion(); - - [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr sqlite3_dylibversion(); - - [DllImport("sqlite3", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr sqlite3_dllversion(); - } -} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/WindowsNativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/WindowsNativeMethods.cs new file mode 100644 index 000000000000..38dd3be89be8 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/WindowsNativeMethods.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibraryWithRid +{ + public static class WindowsNativeMethods + { + [DllImport("sqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_libversion(); + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LinuxNativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LinuxNativeMethods.cs new file mode 100644 index 000000000000..a6c1db7dea45 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LinuxNativeMethods.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibraryWithRids +{ + public static class LinuxNativeMethods + { + [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_libversion(); + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/MacNativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/MacNativeMethods.cs new file mode 100644 index 000000000000..7aa87faf5256 --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/MacNativeMethods.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibraryWithRids +{ + public static class MacNativeMethods + { + [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_libversion(); + } +} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs index ae135b16c756..36b4a900b96c 100755 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs @@ -11,11 +11,11 @@ public static string InvokeNativeCodeAndReturnAString() switch(GetRidStoredInAssemblyDescriptionAttribute()) { case "'ubuntu.14.04-x64'": - return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_libversion()); + return Marshal.PtrToStringAnsi(LinuxNativeMethods.sqlite3_libversion()); case "'osx.10.11-x64'": - return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dylibversion()); + return Marshal.PtrToStringAnsi(MacNativeMethods.sqlite3_libversion()); case "'win10-x64'": - return Marshal.PtrToStringAnsi(NativeMethod.sqlite3_dllversion()); + return Marshal.PtrToStringAnsi(WindowsNativeMethods.sqlite3_libversion()); default: return "Unexpected RID. Cannot find sqlite3."; } diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs deleted file mode 100644 index 4258a4ee533e..000000000000 --- a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeMethods.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace LibraryWithRids -{ - public static class NativeMethod - { - [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr sqlite3_libversion(); - - [DllImport("libsqlite3", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr sqlite3_dylibversion(); - - [DllImport("sqlite3", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr sqlite3_dllversion(); - } -} diff --git a/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/WindowsNativeMethods.cs b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/WindowsNativeMethods.cs new file mode 100644 index 000000000000..f8f6f8b1838b --- /dev/null +++ b/TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/WindowsNativeMethods.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibraryWithRids +{ + public static class WindowsNativeMethods + { + [DllImport("sqlite3", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr sqlite3_libversion(); + } +} From 7f5553c4428edb2a8c8aaa4213d5683443832e74 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Feb 2017 18:29:03 -0800 Subject: [PATCH 20/20] Disable test on Desktop MSBuild --- build/build.proj | 1 + .../GivenThatWeWantToBuildASelfContainedAppWithRid.cs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/build/build.proj b/build/build.proj index c074ab4c7341..cf902eb3571a 100644 --- a/build/build.proj +++ b/build/build.proj @@ -164,6 +164,7 @@ DestinationFolder="$(TestsDirectory)" /> +