-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Enable P2P's to determine their own compilation RID #828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TheRealPiotrP
merged 20 commits into
dotnet:master
from
TheRealPiotrP:piotrpMSFT/issues/696/p2pbuild-r
Feb 16, 2017
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
122974c
Initial test asset
6e4147e
Red test
bc0ed40
Enable building Portable P2P dependencies of RID-specific projects
bf2aec9
PR feedback
7a3a4ce
Avoid RuntimeIdentifer override if ReferringRuntimeIdentifier == ''
ad9f19e
Override Runtime Identifier IFF this proj portable & referring is not
df90c6d
Detect Global RuntimeIdentifier
3838328
Comments.
4b47036
Account for Rainer's feedback.
d9d3d55
Missing quote
98e2390
Update CLI
78a0bd4
Remove accidentally added .vscode files
5996796
add .vscode to .gitignore
13fc5dd
Add missing RIDs
27381b7
PR feedback
ad42880
Add missing RIDs to Lib
4235a57
RID-specific lib...
46f63c5
Fix switch conditions
62ad144
Fix x-plat native invocation
7f5553c
Disable test on Desktop MSBuild
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0-rc4-004771 | ||
1.0.0-rc4-004828 |
15 changes: 15 additions & 0 deletions
15
TestAssets/TestProjects/AppWithLibraryAndRid/App/App.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp1.0</TargetFramework> | ||
<RuntimeIdentifiers>osx.10.11-x64;ubuntu.14.04-x64;win10-x64</RuntimeIdentifiers> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\LibraryWithRid\LibraryWithRid.csproj" /> | ||
<ProjectReference Include="..\LibraryWithRids\LibraryWithRids.csproj" /> | ||
<ProjectReference Include="..\LibraryWithoutRid\LibraryWithoutRid.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
26 changes: 26 additions & 0 deletions
26
TestAssets/TestProjects/AppWithLibraryAndRid/App/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
|
||
namespace App | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var libraryWithRidNativeOutput = LibraryWithRid.NativeCode.InvokeNativeCodeAndReturnAString(); | ||
|
||
var libraryWithRidsNativeOutput = LibraryWithRid.NativeCode.InvokeNativeCodeAndReturnAString(); | ||
|
||
var libraryWithRidCompileTimeRid = LibraryWithRid.NativeCode.GetRidStoredInAssemblyDescriptionAttribute(); | ||
|
||
var libraryWithRidsCompileTimeRid = LibraryWithRids.NativeCode.GetRidStoredInAssemblyDescriptionAttribute(); | ||
|
||
var libraryWithRidStatus = $"{libraryWithRidNativeOutput} {libraryWithRidCompileTimeRid}"; | ||
|
||
var libraryWithRidsStatus = $"{libraryWithRidsNativeOutput} {libraryWithRidsCompileTimeRid}"; | ||
|
||
var portableLibraryStatus = LibraryWithoutRid.PortableClass.GetHelloWorld(); | ||
|
||
Console.WriteLine($"{libraryWithRidStatus} {libraryWithRidsStatus} {portableLibraryStatus}"); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LibraryWithRid.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard1.4</TargetFramework> | ||
<RuntimeIdentifier>$(TestRuntimeIdentifier)</RuntimeIdentifier> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<Description>'$(RuntimeIdentifier)'</Description> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="SQLite"> | ||
<Version>3.13.0</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
11 changes: 11 additions & 0 deletions
11
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/LinuxNativeMethods.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/MacNativeMethods.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/NativeCode.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace LibraryWithRid | ||
{ | ||
public class NativeCode | ||
{ | ||
public static string InvokeNativeCodeAndReturnAString() | ||
{ | ||
switch(GetRidStoredInAssemblyDescriptionAttribute()) | ||
{ | ||
case "'ubuntu.14.04-x64'": | ||
return Marshal.PtrToStringAnsi(LinuxNativeMethods.sqlite3_libversion()); | ||
case "'osx.10.11-x64'": | ||
return Marshal.PtrToStringAnsi(MacNativeMethods.sqlite3_libversion()); | ||
case "'win10-x64'": | ||
return Marshal.PtrToStringAnsi(WindowsNativeMethods.sqlite3_libversion()); | ||
default: | ||
return "Unexpected RID. Cannot find sqlite3."; | ||
} | ||
} | ||
|
||
public static string GetRidStoredInAssemblyDescriptionAttribute() | ||
{ | ||
return typeof(NativeCode) | ||
.GetTypeInfo() | ||
.Assembly | ||
.GetCustomAttribute<AssemblyDescriptionAttribute>() | ||
?.Description; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRid/WindowsNativeMethods.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LibraryWithRids.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard1.4</TargetFramework> | ||
<RuntimeIdentifiers>osx.10.11-x64;ubuntu.14.04-x64;win10-x64</RuntimeIdentifiers> | ||
<Description>'$(RuntimeIdentifier)'</Description> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="SQLite"> | ||
<Version>3.13.0</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
11 changes: 11 additions & 0 deletions
11
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/LinuxNativeMethods.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/MacNativeMethods.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/NativeCode.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace LibraryWithRids | ||
{ | ||
public class NativeCode | ||
{ | ||
public static string InvokeNativeCodeAndReturnAString() | ||
{ | ||
switch(GetRidStoredInAssemblyDescriptionAttribute()) | ||
{ | ||
case "'ubuntu.14.04-x64'": | ||
return Marshal.PtrToStringAnsi(LinuxNativeMethods.sqlite3_libversion()); | ||
case "'osx.10.11-x64'": | ||
return Marshal.PtrToStringAnsi(MacNativeMethods.sqlite3_libversion()); | ||
case "'win10-x64'": | ||
return Marshal.PtrToStringAnsi(WindowsNativeMethods.sqlite3_libversion()); | ||
default: | ||
return "Unexpected RID. Cannot find sqlite3."; | ||
} | ||
} | ||
|
||
public static string GetRidStoredInAssemblyDescriptionAttribute() | ||
{ | ||
return typeof(NativeCode) | ||
.GetTypeInfo() | ||
.Assembly | ||
.GetCustomAttribute<AssemblyDescriptionAttribute>() | ||
?.Description; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithRids/WindowsNativeMethods.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/LibraryWithoutRid.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard1.4</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
12 changes: 12 additions & 0 deletions
12
TestAssets/TestProjects/AppWithLibraryAndRid/LibraryWithoutRid/PortableCode.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace LibraryWithoutRid | ||
{ | ||
public class PortableClass | ||
{ | ||
public static string GetHelloWorld() | ||
{ | ||
return "Hello World"; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedAppWithRid.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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 Xunit; | ||
using static Microsoft.NET.TestFramework.Commands.MSBuildTest; | ||
|
||
namespace Microsoft.NET.Build.Tests | ||
{ | ||
public class GivenThatWeWantToBuildASelfContainedAppWithLibrariesAndRid : SdkTest | ||
{ | ||
[Fact] | ||
public void It_builds_a_RID_specific_runnable_output() | ||
{ | ||
if (UsingFullFrameworkMSBuild) | ||
{ | ||
// Disable this test on full framework, as the current build won't have access to | ||
// https://github.com/Microsoft/msbuild/pull/1674 | ||
// See https://github.com/dotnet/sdk/issues/877 | ||
return; | ||
} | ||
|
||
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($"/p:TestRuntimeIdentifier={runtimeIdentifier}") | ||
.Should() | ||
.Pass(); | ||
|
||
var buildCommand = new BuildCommand(Stage0MSBuild, projectPath); | ||
|
||
buildCommand | ||
.Execute($"/p:RuntimeIdentifier={runtimeIdentifier}", $"/p:TestRuntimeIdentifier={runtimeIdentifier}") | ||
.Should() | ||
.Pass(); | ||
|
||
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.0"); | ||
var selfContainedExecutable = $"App{Constants.ExeSuffix}"; | ||
|
||
Command.Create(Path.Combine(outputDirectory.FullName, selfContainedExecutable), new string[] { }) | ||
.CaptureStdOut() | ||
.Execute() | ||
.Should() | ||
.Pass() | ||
.And | ||
.HaveStdOutContaining($"3.13.0 '{runtimeIdentifier}' 3.13.0 '{runtimeIdentifier}' Hello World"); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to check this in? I like it, but the formatting is off and it would be nice not to duplicate the command in Message and Exec.