Merge pull request #2684 from dotnet/pakrym/desktop-standalone

Fix desktop standalone scenario
This commit is contained in:
Pavel Krymets 2016-04-27 18:23:44 -07:00
commit 40b96398b8
6 changed files with 65 additions and 12 deletions

View file

@ -0,0 +1,11 @@
using System;
namespace DesktopAppWithRuntimes
{
public static class Program
{
public static void Main(string[] args)
{
}
}
}

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.Windows.ApiSets": "1.0.1-rc2-*"
},
"compilationOptions": {
"emitEntryPoint": true
},
"frameworks": {
"net451": {}
},
"runtimes":
{
"win7-x64": {}
}
}

View file

@ -252,7 +252,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
compilerOptions: includeCompile ? _compilerOptions : null,
compilationExports: includeCompile ? exports : null,
runtimeExports: exports,
portable: string.IsNullOrEmpty(_context.RuntimeIdentifier),
portable: _context.IsPortable,
target: _context.TargetFramework,
runtime: _context.RuntimeIdentifier ?? string.Empty);

View file

@ -241,7 +241,7 @@ namespace Microsoft.DotNet.ProjectModel
.Cast<LibraryRange?>()
.FirstOrDefault();
}
bool isPortable = platformDependency != null || TargetFramework.IsDesktop();
bool isPortable = platformDependency != null;
LockFileTarget target = null;
LibraryDescription platformLibrary = null;
@ -262,9 +262,11 @@ namespace Microsoft.DotNet.ProjectModel
}
}
string runtime;
if (TargetFramework.IsDesktop())
string runtime = target?.RuntimeIdentifier;
if (string.IsNullOrEmpty(runtime) && TargetFramework.IsDesktop())
{
// we got a ridless target for desktop so turning portable mode on
isPortable = true;
var legacyRuntime = PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier();
if (RuntimeIdentifiers.Contains(legacyRuntime))
{
@ -275,10 +277,6 @@ namespace Microsoft.DotNet.ProjectModel
runtime = RuntimeIdentifiers.FirstOrDefault();
}
}
else
{
runtime = target?.RuntimeIdentifier;
}
var referenceAssemblyDependencyResolver = new ReferenceAssemblyDependencyResolver(frameworkReferenceResolver);
bool requiresFrameworkAssemblies;

View file

@ -15,6 +15,13 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
{
public class PublishDesktopTests : TestBase
{
private TestAssetsManager _testAssetsManager;
public PublishDesktopTests()
{
_testAssetsManager = GetTestGroupTestAssetsManager("DesktopTestProjects");
}
[WindowsOnlyTheory]
[InlineData(null, null)]
[InlineData("win7-x64", "the-win-x64-version.txt")]
@ -26,7 +33,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
expectedOutputName = $"the-win-{RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant()}-version.txt";
}
var testInstance = TestAssetsManager.CreateTestInstance(Path.Combine("..", "DesktopTestProjects", "DesktopAppWithNativeDep"))
var testInstance = _testAssetsManager.CreateTestInstance("DesktopAppWithNativeDep")
.WithLockFiles();
var publishCommand = new PublishCommand(testInstance.TestRoot, runtime: runtime);
@ -55,7 +62,9 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
var testInstance = GetTestInstance()
.WithLockFiles();
var publishCommand = new PublishCommand(Path.Combine(testInstance.TestRoot, project), runtime: runtime);
// Prevent path too long failure on CI machines
var projectPath = Path.Combine(testInstance.TestRoot, project);
var publishCommand = new PublishCommand(projectPath, runtime: runtime, output: Path.Combine(projectPath, "out"));
var result = await publishCommand.ExecuteAsync();
result.Should().Pass();
@ -123,9 +132,28 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
}
}
private static TestInstance GetTestInstance([CallerMemberName] string callingMethod = "")
[WindowsOnlyFact]
public async Task DesktopApp_WithRuntimes_PublishedSplitPackageAssets()
{
return TestAssetsManager.CreateTestInstance(Path.Combine("..", "DesktopTestProjects", "DesktopKestrelSample"), callingMethod);
var testInstance = _testAssetsManager.CreateTestInstance("DesktopAppWithRuntimes")
.WithLockFiles();
var publishCommand = new PublishCommand(testInstance.TestRoot, runtime: "win7-x64");
var result = await publishCommand.ExecuteAsync();
result.Should().Pass();
// Test the output
var outputDir = publishCommand.GetOutputDirectory(portable: false);
System.Console.WriteLine(outputDir);
outputDir.Should().HaveFile("api-ms-win-core-file-l1-1-0.dll");
outputDir.Should().HaveFile(publishCommand.GetOutputExecutable());
}
private TestInstance GetTestInstance([CallerMemberName] string callingMethod = "")
{
return _testAssetsManager.CreateTestInstance("DesktopKestrelSample", callingMethod);
}
}
}