Do not trim refs
This commit is contained in:
parent
f665c28173
commit
8831bb4a8b
31 changed files with 455 additions and 108 deletions
|
@ -44,6 +44,7 @@ namespace Microsoft.Extensions.DependencyModel
|
||||||
var resolvedPaths = compilationLibrary.ResolveReferencePaths();
|
var resolvedPaths = compilationLibrary.ResolveReferencePaths();
|
||||||
foreach (var resolvedPath in resolvedPaths)
|
foreach (var resolvedPath in resolvedPaths)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Compilation {compilationLibrary.Name}:{Path.GetFileName(resolvedPath)}");
|
||||||
if (!File.Exists(resolvedPath))
|
if (!File.Exists(resolvedPath))
|
||||||
{
|
{
|
||||||
Error($"Compilataion library resolved to non existent path {resolvedPath}");
|
Error($"Compilataion library resolved to non existent path {resolvedPath}");
|
||||||
|
@ -55,8 +56,10 @@ namespace Microsoft.Extensions.DependencyModel
|
||||||
foreach (var runtimeLibrary in context.RuntimeLibraries)
|
foreach (var runtimeLibrary in context.RuntimeLibraries)
|
||||||
{
|
{
|
||||||
CheckMetadata(runtimeLibrary);
|
CheckMetadata(runtimeLibrary);
|
||||||
foreach (var assembly in runtimeLibrary.GetDefaultNativeAssets(context)) {}
|
foreach (var native in runtimeLibrary.GetDefaultNativeAssets(context)) {}
|
||||||
foreach (var native in runtimeLibrary.GetDefaultAssemblyNames(context)) {}
|
foreach (var assembly in runtimeLibrary.GetDefaultAssemblyNames(context)) {
|
||||||
|
Console.WriteLine($"Runtime {runtimeLibrary.Name}:{assembly.Name}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var native in context.GetDefaultNativeAssets()) {}
|
foreach (var native in context.GetDefaultNativeAssets()) {}
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NETStandard.Library": "1.5.0-rc2-23931",
|
|
||||||
"Microsoft.Extensions.DependencyModel": {
|
"Microsoft.Extensions.DependencyModel": {
|
||||||
"target": "project",
|
"target": "project",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"netstandardapp1.5": {
|
"netstandard1.5": {
|
||||||
"imports": "dnxcore50"
|
"imports": "dnxcore50",
|
||||||
|
"dependencies": {
|
||||||
|
"NETStandard.Library": "1.5.0-rc2-23931",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"net451": {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
// 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 System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Microsoft.Extensions.DependencyModel.DependencyContextValidator.Validate(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true,
|
||||||
|
"preserveCompilationContext": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"DependencyContextValidator": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net451": {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
// 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 System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Microsoft.Extensions.DependencyModel.DependencyContextValidator.Validate(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true,
|
||||||
|
"preserveCompilationContext": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0-rc2-23931"
|
||||||
|
},
|
||||||
|
"DependencyContextValidator": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netstandard1.5": {
|
||||||
|
"imports" : "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
// 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 System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Microsoft.Extensions.DependencyModel.DependencyContextValidator.Validate(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true,
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0-rc2-23931"
|
||||||
|
},
|
||||||
|
"DependencyContextValidator": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netstandard1.5": {
|
||||||
|
"imports" : "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace PortableApp
|
||||||
|
{
|
||||||
|
public static class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello, World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true,
|
||||||
|
"preserveCompilationContext": true
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"frameworks": {
|
||||||
|
"netstandard1.5": {
|
||||||
|
"imports": [
|
||||||
|
"dnxcore50",
|
||||||
|
"portable-net45+win8"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0-rc2-23931"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Microsoft.DotNet.Cli.Build.Framework;
|
using Microsoft.DotNet.Cli.Build.Framework;
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
using Microsoft.Extensions.PlatformAbstractions;
|
||||||
|
@ -9,6 +10,8 @@ using static Microsoft.DotNet.Cli.Build.FS;
|
||||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Reflection.PortableExecutable;
|
using System.Reflection.PortableExecutable;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Build
|
namespace Microsoft.DotNet.Cli.Build
|
||||||
{
|
{
|
||||||
|
@ -352,6 +355,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
// Rename the .deps file
|
// Rename the .deps file
|
||||||
var destinationDeps = Path.Combine(SharedFrameworkNameAndVersionRoot, $"{SharedFrameworkName}.deps.json");
|
var destinationDeps = Path.Combine(SharedFrameworkNameAndVersionRoot, $"{SharedFrameworkName}.deps.json");
|
||||||
File.Move(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.deps.json"), destinationDeps);
|
File.Move(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.deps.json"), destinationDeps);
|
||||||
|
ChangeEntryPointLibraryName(destinationDeps, null);
|
||||||
|
|
||||||
// Generate RID fallback graph
|
// Generate RID fallback graph
|
||||||
string runtimeGraphGeneratorRuntime = null;
|
string runtimeGraphGeneratorRuntime = null;
|
||||||
|
@ -445,7 +449,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
"--output",
|
"--output",
|
||||||
outputDir,
|
outputDir,
|
||||||
"--framework",
|
"--framework",
|
||||||
"netstandard1.5")
|
"netstandard1.5")
|
||||||
.Execute()
|
.Execute()
|
||||||
.EnsureSuccessful();
|
.EnsureSuccessful();
|
||||||
|
|
||||||
|
@ -468,6 +472,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
File.Delete(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"));
|
File.Delete(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"));
|
||||||
File.Copy(compilersDeps, Path.Combine(outputDir, binaryToCorehostify + ".deps.json"));
|
File.Copy(compilersDeps, Path.Combine(outputDir, binaryToCorehostify + ".deps.json"));
|
||||||
File.Copy(compilersRuntimeConfig, Path.Combine(outputDir, binaryToCorehostify + ".runtimeconfig.json"));
|
File.Copy(compilersRuntimeConfig, Path.Combine(outputDir, binaryToCorehostify + ".runtimeconfig.json"));
|
||||||
|
ChangeEntryPointLibraryName(Path.Combine(outputDir, binaryToCorehostify + ".deps.json"), binaryToCorehostify);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -577,6 +582,42 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
return c.Success();
|
return c.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ChangeEntryPointLibraryName(string depsFile, string newName)
|
||||||
|
{
|
||||||
|
JToken deps;
|
||||||
|
using (var file = File.OpenText(depsFile))
|
||||||
|
using (JsonTextReader reader = new JsonTextReader(file))
|
||||||
|
{
|
||||||
|
deps = JObject.ReadFrom(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
var target = deps["targets"][deps["runtimeTarget"]["name"].Value<string>()];
|
||||||
|
var library = target.Children<JProperty>().First();
|
||||||
|
var version = library.Name.Substring(library.Name.IndexOf('/') + 1);
|
||||||
|
if (newName == null)
|
||||||
|
{
|
||||||
|
library.Remove();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
library.Replace(new JProperty(newName + '/' + version, library.Value));
|
||||||
|
}
|
||||||
|
library = deps["libraries"].Children<JProperty>().First();
|
||||||
|
if (newName == null)
|
||||||
|
{
|
||||||
|
library.Remove();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
library.Replace(new JProperty(newName + '/' + version, library.Value));
|
||||||
|
}
|
||||||
|
using (var file = File.CreateText(depsFile))
|
||||||
|
using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented})
|
||||||
|
{
|
||||||
|
deps.WriteTo(writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void DeleteMainPublishOutput(string path, string name)
|
private static void DeleteMainPublishOutput(string path, string name)
|
||||||
{
|
{
|
||||||
File.Delete(Path.Combine(path, $"{name}{Constants.ExeSuffix}"));
|
File.Delete(Path.Combine(path, $"{name}{Constants.ExeSuffix}"));
|
||||||
|
|
|
@ -205,8 +205,8 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
{
|
{
|
||||||
var dotnet = DotNetCli.Stage0;
|
var dotnet = DotNetCli.Stage0;
|
||||||
|
|
||||||
dotnet.Restore("--verbosity", "verbose").WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "src")).Execute().EnsureSuccessful();
|
dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--infer-runtimes").WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "src")).Execute().EnsureSuccessful();
|
||||||
dotnet.Restore("--verbosity", "verbose", "--infer-runtimes").WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "tools")).Execute().EnsureSuccessful();
|
dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--infer-runtimes").WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "tools")).Execute().EnsureSuccessful();
|
||||||
|
|
||||||
return c.Success();
|
return c.Success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
if (string.Equals(Path.GetFileName(candidate), "bin") ||
|
if (string.Equals(Path.GetFileName(candidate), "bin") ||
|
||||||
string.Equals(Path.GetFileName(candidate), "obj"))
|
string.Equals(Path.GetFileName(candidate), "obj"))
|
||||||
{
|
{
|
||||||
Directory.Delete(candidate, recursive: true);
|
Utils.DeleteDirectory(candidate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,8 +96,24 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
File.SetAttributes(file, FileAttributes.Normal);
|
File.SetAttributes(file, FileAttributes.Normal);
|
||||||
File.Delete(file);
|
File.Delete(file);
|
||||||
}
|
}
|
||||||
System.Threading.Thread.Sleep(1);
|
var retry = 5;
|
||||||
Directory.Delete(path, true);
|
while (retry >= 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.Delete(path, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
if (retry == 0)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
System.Threading.Thread.Sleep(200);
|
||||||
|
retry--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -424,7 +424,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
|
|
||||||
private IEnumerable<LibraryAsset> PopulateAssets(TargetLibraryWithAssets library, IEnumerable<LockFileItem> section)
|
private IEnumerable<LibraryAsset> PopulateAssets(TargetLibraryWithAssets library, IEnumerable<LockFileItem> section)
|
||||||
{
|
{
|
||||||
foreach (var assemblyPath in section)
|
foreach (var assemblyPath in section.Where(a => !PackageDependencyProvider.IsPlaceholderFile(a.Path)))
|
||||||
{
|
{
|
||||||
yield return LibraryAsset.CreateFromRelativePath(library.Path, assemblyPath.Path);
|
yield return LibraryAsset.CreateFromRelativePath(library.Path, assemblyPath.Path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using Microsoft.DotNet.ProjectModel.Files;
|
using Microsoft.DotNet.ProjectModel.Files;
|
||||||
using Microsoft.DotNet.ProjectModel.Graph;
|
using Microsoft.DotNet.ProjectModel.Graph;
|
||||||
using NuGet.Frameworks;
|
using NuGet.Frameworks;
|
||||||
|
@ -91,7 +92,7 @@ namespace Microsoft.DotNet.ProjectModel
|
||||||
public string RawRuntimeOptions { get; set; }
|
public string RawRuntimeOptions { get; set; }
|
||||||
|
|
||||||
public bool IsTestProject => !string.IsNullOrEmpty(TestRunner);
|
public bool IsTestProject => !string.IsNullOrEmpty(TestRunner);
|
||||||
|
|
||||||
public IEnumerable<TargetFrameworkInformation> GetTargetFrameworks()
|
public IEnumerable<TargetFrameworkInformation> GetTargetFrameworks()
|
||||||
{
|
{
|
||||||
return _targetFrameworks.Values;
|
return _targetFrameworks.Values;
|
||||||
|
|
|
@ -145,11 +145,8 @@ namespace Microsoft.DotNet.ProjectModel
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there are any runtime targets (i.e. are we portable)
|
var standalone = !ProjectFile.Dependencies.Any(d => d.Type.Equals(LibraryDependencyType.Platform));
|
||||||
var standalone = LockFile.Targets
|
|
||||||
.Where(t => t.TargetFramework.Equals(TargetFramework))
|
|
||||||
.Any(t => !string.IsNullOrEmpty(t.RuntimeIdentifier));
|
|
||||||
|
|
||||||
var context = CreateBuilder(ProjectFile.ProjectFilePath, TargetFramework)
|
var context = CreateBuilder(ProjectFile.ProjectFilePath, TargetFramework)
|
||||||
.WithRuntimeIdentifiers(standalone ? runtimeIdentifiers : Enumerable.Empty<string>())
|
.WithRuntimeIdentifiers(standalone ? runtimeIdentifiers : Enumerable.Empty<string>())
|
||||||
|
|
|
@ -12,41 +12,101 @@ namespace Microsoft.Extensions.DependencyModel
|
||||||
|
|
||||||
public static IEnumerable<string> GetDefaultNativeAssets(this DependencyContext self)
|
public static IEnumerable<string> GetDefaultNativeAssets(this DependencyContext self)
|
||||||
{
|
{
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(self));
|
||||||
|
}
|
||||||
return self.RuntimeLibraries.SelectMany(library => library.GetDefaultNativeAssets(self));
|
return self.RuntimeLibraries.SelectMany(library => library.GetDefaultNativeAssets(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<string> GetRuntimeNativeAssets(this DependencyContext self, string runtimeIdentifier)
|
public static IEnumerable<string> GetRuntimeNativeAssets(this DependencyContext self, string runtimeIdentifier)
|
||||||
{
|
{
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(self));
|
||||||
|
}
|
||||||
|
if (runtimeIdentifier == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(runtimeIdentifier));
|
||||||
|
}
|
||||||
return self.RuntimeLibraries.SelectMany(library => library.GetRuntimeNativeAssets(self, runtimeIdentifier));
|
return self.RuntimeLibraries.SelectMany(library => library.GetRuntimeNativeAssets(self, runtimeIdentifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<string> GetDefaultNativeAssets(this RuntimeLibrary self, DependencyContext context)
|
public static IEnumerable<string> GetDefaultNativeAssets(this RuntimeLibrary self, DependencyContext context)
|
||||||
{
|
{
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(self));
|
||||||
|
}
|
||||||
return ResolveAssets(context, string.Empty, self.NativeLibraryGroups);
|
return ResolveAssets(context, string.Empty, self.NativeLibraryGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<string> GetRuntimeNativeAssets(this RuntimeLibrary self, DependencyContext context, string runtimeIdentifier)
|
public static IEnumerable<string> GetRuntimeNativeAssets(this RuntimeLibrary self, DependencyContext context, string runtimeIdentifier)
|
||||||
{
|
{
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(self));
|
||||||
|
}
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
if (runtimeIdentifier == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(runtimeIdentifier));
|
||||||
|
}
|
||||||
return ResolveAssets(context, runtimeIdentifier, self.NativeLibraryGroups);
|
return ResolveAssets(context, runtimeIdentifier, self.NativeLibraryGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<AssemblyName> GetDefaultAssemblyNames(this DependencyContext self)
|
public static IEnumerable<AssemblyName> GetDefaultAssemblyNames(this DependencyContext self)
|
||||||
{
|
{
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(self));
|
||||||
|
}
|
||||||
return self.RuntimeLibraries.SelectMany(library => library.GetDefaultAssemblyNames(self));
|
return self.RuntimeLibraries.SelectMany(library => library.GetDefaultAssemblyNames(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<AssemblyName> GetRuntimeAssemblyNames(this DependencyContext self, string runtimeIdentifier)
|
public static IEnumerable<AssemblyName> GetRuntimeAssemblyNames(this DependencyContext self, string runtimeIdentifier)
|
||||||
{
|
{
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(self));
|
||||||
|
}
|
||||||
|
if (runtimeIdentifier == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(runtimeIdentifier));
|
||||||
|
}
|
||||||
return self.RuntimeLibraries.SelectMany(library => library.GetRuntimeAssemblyNames(self, runtimeIdentifier));
|
return self.RuntimeLibraries.SelectMany(library => library.GetRuntimeAssemblyNames(self, runtimeIdentifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<AssemblyName> GetDefaultAssemblyNames(this RuntimeLibrary self, DependencyContext context)
|
public static IEnumerable<AssemblyName> GetDefaultAssemblyNames(this RuntimeLibrary self, DependencyContext context)
|
||||||
{
|
{
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(self));
|
||||||
|
}
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
return ResolveAssets(context, string.Empty, self.RuntimeAssemblyGroups).Select(GetAssemblyName);
|
return ResolveAssets(context, string.Empty, self.RuntimeAssemblyGroups).Select(GetAssemblyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<AssemblyName> GetRuntimeAssemblyNames(this RuntimeLibrary self, DependencyContext context, string runtimeIdentifier)
|
public static IEnumerable<AssemblyName> GetRuntimeAssemblyNames(this RuntimeLibrary self, DependencyContext context, string runtimeIdentifier)
|
||||||
{
|
{
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(self));
|
||||||
|
}
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
if (runtimeIdentifier == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(runtimeIdentifier));
|
||||||
|
}
|
||||||
return ResolveAssets(context, runtimeIdentifier, self.RuntimeAssemblyGroups).Select(GetAssemblyName);
|
return ResolveAssets(context, runtimeIdentifier, self.RuntimeAssemblyGroups).Select(GetAssemblyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,8 @@ namespace Microsoft.Extensions.DependencyModel
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CompilationOptions(
|
return new CompilationOptions(
|
||||||
compilationOptionsObject[DependencyContextStrings.DefinesPropertyName]?.Values<string>() ?? Enumerable.Empty<string>(),
|
compilationOptionsObject[DependencyContextStrings.DefinesPropertyName]?.Values<string>().ToArray() ?? Enumerable.Empty<string>(),
|
||||||
|
// ToArray is here to prevent IEnumerable<string> holding to json object graph
|
||||||
compilationOptionsObject[DependencyContextStrings.LanguageVersionPropertyName]?.Value<string>(),
|
compilationOptionsObject[DependencyContextStrings.LanguageVersionPropertyName]?.Value<string>(),
|
||||||
compilationOptionsObject[DependencyContextStrings.PlatformPropertyName]?.Value<string>(),
|
compilationOptionsObject[DependencyContextStrings.PlatformPropertyName]?.Value<string>(),
|
||||||
compilationOptionsObject[DependencyContextStrings.AllowUnsafePropertyName]?.Value<bool>(),
|
compilationOptionsObject[DependencyContextStrings.AllowUnsafePropertyName]?.Value<bool>(),
|
||||||
|
|
|
@ -131,22 +131,26 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
var isPortable = string.IsNullOrEmpty(context.RuntimeIdentifier);
|
var isPortable = string.IsNullOrEmpty(context.RuntimeIdentifier);
|
||||||
|
|
||||||
// Collect all exports and organize them
|
// Collect all exports and organize them
|
||||||
var exports = exporter.GetAllExports()
|
var packageExports = exporter.GetAllExports()
|
||||||
.Where(e => e.Library.Identity.Type.Equals(LibraryType.Package))
|
.Where(e => e.Library.Identity.Type.Equals(LibraryType.Package))
|
||||||
.ToDictionary(e => e.Library.Identity.Name);
|
.ToDictionary(e => e.Library.Identity.Name);
|
||||||
var collectExclusionList = isPortable ? GetExclusionList(context, exports) : new HashSet<string>();
|
var collectExclusionList = isPortable ? GetExclusionList(context, packageExports) : new HashSet<string>();
|
||||||
|
|
||||||
foreach (var export in exporter.GetAllExports().Where(e => !collectExclusionList.Contains(e.Library.Identity.Name)))
|
var exports = exporter.GetAllExports();
|
||||||
|
foreach (var export in exports.Where(e => !collectExclusionList.Contains(e.Library.Identity.Name)))
|
||||||
{
|
{
|
||||||
Reporter.Verbose.WriteLine($"Publishing {export.Library.Identity.ToString().Green().Bold()} ...");
|
Reporter.Verbose.WriteLine($"Publishing {export.Library.Identity.ToString().Green().Bold()} ...");
|
||||||
|
|
||||||
PublishAssetGroups(export.RuntimeAssemblyGroups, outputPath, nativeSubdirectories: false, includeRuntimeGroups: isPortable);
|
PublishAssetGroups(export.RuntimeAssemblyGroups, outputPath, nativeSubdirectories: false, includeRuntimeGroups: isPortable);
|
||||||
PublishAssetGroups(export.NativeLibraryGroups, outputPath, nativeSubdirectories, includeRuntimeGroups: isPortable);
|
PublishAssetGroups(export.NativeLibraryGroups, outputPath, nativeSubdirectories, includeRuntimeGroups: isPortable);
|
||||||
export.RuntimeAssets.StructuredCopyTo(outputPath, outputPaths.IntermediateOutputDirectoryPath);
|
export.RuntimeAssets.StructuredCopyTo(outputPath, outputPaths.IntermediateOutputDirectoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
if (options.PreserveCompilationContext.GetValueOrDefault())
|
if (options.PreserveCompilationContext.GetValueOrDefault())
|
||||||
|
{
|
||||||
|
foreach (var export in exports)
|
||||||
{
|
{
|
||||||
PublishRefs(export, outputPath);
|
PublishRefs(export, outputPath, !collectExclusionList.Contains(export.Library.Identity.Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,19 +252,19 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PublishRefs(LibraryExport export, string outputPath)
|
private static void PublishRefs(LibraryExport export, string outputPath, bool deduplicate)
|
||||||
{
|
{
|
||||||
var refsPath = Path.Combine(outputPath, "refs");
|
var refsPath = Path.Combine(outputPath, "refs");
|
||||||
if (!Directory.Exists(refsPath))
|
if (!Directory.Exists(refsPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(refsPath);
|
Directory.CreateDirectory(refsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not copy compilation assembly if it's in runtime assemblies
|
// Do not copy compilation assembly if it's in runtime assemblies
|
||||||
var runtimeAssemblies = new HashSet<LibraryAsset>(export.RuntimeAssemblyGroups.GetDefaultAssets());
|
var runtimeAssemblies = new HashSet<LibraryAsset>(export.RuntimeAssemblyGroups.GetDefaultAssets());
|
||||||
foreach (var compilationAssembly in export.CompilationAssemblies)
|
foreach (var compilationAssembly in export.CompilationAssemblies)
|
||||||
{
|
{
|
||||||
if (!runtimeAssemblies.Contains(compilationAssembly))
|
if (!deduplicate || !runtimeAssemblies.Contains(compilationAssembly))
|
||||||
{
|
{
|
||||||
var destFileName = Path.Combine(refsPath, Path.GetFileName(compilationAssembly.ResolvedPath));
|
var destFileName = Path.Combine(refsPath, Path.GetFileName(compilationAssembly.ResolvedPath));
|
||||||
File.Copy(compilationAssembly.ResolvedPath, destFileName, overwrite: true);
|
File.Copy(compilationAssembly.ResolvedPath, destFileName, overwrite: true);
|
||||||
|
@ -358,67 +362,16 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
|
|
||||||
private IEnumerable<ProjectContext> SelectContexts(string projectPath, NuGetFramework framework, string runtime)
|
private IEnumerable<ProjectContext> SelectContexts(string projectPath, NuGetFramework framework, string runtime)
|
||||||
{
|
{
|
||||||
var allContexts = ProjectContext.CreateContextForEachTarget(projectPath).ToList();
|
var allContexts = framework == null ?
|
||||||
var frameworks = framework == null ?
|
ProjectContext.CreateContextForEachFramework(projectPath) :
|
||||||
allContexts.Select(c => c.TargetFramework).Distinct().ToArray() :
|
new[] { ProjectContext.Create(projectPath, framework) };
|
||||||
new[] { framework };
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(runtime))
|
var runtimes = !string.IsNullOrEmpty(runtime) ?
|
||||||
{
|
new [] {runtime} :
|
||||||
// For each framework, find the best matching RID item
|
PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers();
|
||||||
var candidates = PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers();
|
return allContexts.Select(c => c.CreateRuntimeContext(runtimes));
|
||||||
return frameworks.Select(f => FindBestTarget(f, allContexts, candidates));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return frameworks.SelectMany(f => allContexts.Where(c =>
|
|
||||||
Equals(c.TargetFramework, f) &&
|
|
||||||
string.Equals(c.RuntimeIdentifier, runtime, StringComparison.Ordinal)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProjectContext FindBestTarget(NuGetFramework f, List<ProjectContext> allContexts, IEnumerable<string> candidates)
|
|
||||||
{
|
|
||||||
foreach (var candidate in candidates)
|
|
||||||
{
|
|
||||||
var target = allContexts.FirstOrDefault(c =>
|
|
||||||
Equals(c.TargetFramework, f) &&
|
|
||||||
string.Equals(c.RuntimeIdentifier, candidate, StringComparison.Ordinal));
|
|
||||||
if (target != null)
|
|
||||||
{
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// No RID-specific target found, use the RID-less target and publish portable
|
|
||||||
return allContexts.FirstOrDefault(c =>
|
|
||||||
Equals(c.TargetFramework, f) &&
|
|
||||||
string.IsNullOrEmpty(c.RuntimeIdentifier));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return the matching framework/runtime ProjectContext.
|
|
||||||
/// If 'framework' or 'runtimeIdentifier' is null or empty then it matches with any.
|
|
||||||
/// </summary>
|
|
||||||
private static IEnumerable<ProjectContext> GetMatchingProjectContexts(IEnumerable<ProjectContext> contexts, NuGetFramework framework, string runtimeIdentifier)
|
|
||||||
{
|
|
||||||
foreach (var context in contexts)
|
|
||||||
{
|
|
||||||
if (context.TargetFramework == null || string.IsNullOrEmpty(context.RuntimeIdentifier))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(runtimeIdentifier) || string.Equals(runtimeIdentifier, context.RuntimeIdentifier, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
if (framework == null || framework.Equals(context.TargetFramework))
|
|
||||||
{
|
|
||||||
yield return context;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CopyContents(ProjectContext context, string outputPath)
|
private static void CopyContents(ProjectContext context, string outputPath)
|
||||||
{
|
{
|
||||||
var contentFiles = context.ProjectFile.Files.GetContentFiles();
|
var contentFiles = context.ProjectFile.Files.GetContentFiles();
|
||||||
|
|
|
@ -42,6 +42,7 @@ pushd "$Stage2Dir"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
.\dotnet restore `
|
.\dotnet restore `
|
||||||
|
--infer-runtimes `
|
||||||
$testDir `
|
$testDir `
|
||||||
-f https://www.myget.org/F/dotnet-buildtools/api/v3/index.json | Out-Host
|
-f https://www.myget.org/F/dotnet-buildtools/api/v3/index.json | Out-Host
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
string.Equals("on", val, StringComparison.OrdinalIgnoreCase));
|
string.Equals("on", val, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void TestExecutable(string outputDir,
|
protected CommandResult TestExecutable(string outputDir,
|
||||||
string executableName,
|
string executableName,
|
||||||
string expectedOutput)
|
string expectedOutput)
|
||||||
{
|
{
|
||||||
|
@ -123,9 +123,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
|
|
||||||
var result = executableCommand.ExecuteWithCapturedOutput(string.Join(" ", args));
|
var result = executableCommand.ExecuteWithCapturedOutput(string.Join(" ", args));
|
||||||
|
|
||||||
result.Should().HaveStdOut(expectedOutput);
|
if (!string.IsNullOrEmpty(expectedOutput))
|
||||||
|
{
|
||||||
|
result.Should().HaveStdOut(expectedOutput);
|
||||||
|
}
|
||||||
result.Should().NotHaveStdErr();
|
result.Should().NotHaveStdErr();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void TestOutputExecutable(
|
protected void TestOutputExecutable(
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
using Microsoft.DotNet.TestFramework;
|
||||||
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.Extensions.DependencyModel
|
||||||
|
{
|
||||||
|
public class FunctionalTests : TestBase
|
||||||
|
{
|
||||||
|
private readonly string _testProjectsRoot;
|
||||||
|
|
||||||
|
public FunctionalTests()
|
||||||
|
{
|
||||||
|
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("TestApp", true)]
|
||||||
|
[InlineData("TestAppPortable", true)]
|
||||||
|
[InlineData("TestAppDeps", false)]
|
||||||
|
[InlineData("TestAppPortableDeps", false)]
|
||||||
|
public void RunTest(string appname, bool checkCompilation)
|
||||||
|
{
|
||||||
|
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", appname);
|
||||||
|
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||||
|
|
||||||
|
var runCommand = new RunCommand(testProject);
|
||||||
|
var result = runCommand.ExecuteWithCapturedOutput();
|
||||||
|
result.Should().Pass();
|
||||||
|
ValidateRuntimeLibrarites(result, appname);
|
||||||
|
if (checkCompilation)
|
||||||
|
{
|
||||||
|
ValidateCompilationLibraries(result, appname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("TestApp", false, true)]
|
||||||
|
[InlineData("TestAppPortable", true, true)]
|
||||||
|
[InlineData("TestAppDeps", false, false)]
|
||||||
|
[InlineData("TestAppPortableDeps", true, false)]
|
||||||
|
public void PublishTest(string appname, bool portable, bool checkCompilation)
|
||||||
|
{
|
||||||
|
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", appname);
|
||||||
|
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||||
|
|
||||||
|
var publishCommand = new PublishCommand(testProject);
|
||||||
|
publishCommand.Execute().Should().Pass();
|
||||||
|
|
||||||
|
var exeName = portable ? publishCommand.GetPortableOutputName() : publishCommand.GetOutputExecutable();
|
||||||
|
|
||||||
|
var result = TestExecutable(publishCommand.GetOutputDirectory(portable).FullName, exeName, string.Empty);
|
||||||
|
ValidateRuntimeLibrarites(result, appname);
|
||||||
|
if (checkCompilation)
|
||||||
|
{
|
||||||
|
ValidateCompilationLibraries(result, appname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[WindowsOnlyFact]
|
||||||
|
public void RunTestFullClr()
|
||||||
|
{
|
||||||
|
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestAppFullClr");
|
||||||
|
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||||
|
|
||||||
|
var runCommand = new RunCommand(testProject);
|
||||||
|
var result = runCommand.ExecuteWithCapturedOutput();
|
||||||
|
result.Should().Pass();
|
||||||
|
ValidateRuntimeLibraritesFullClr(result, "TestAppFullClr");
|
||||||
|
ValidateCompilationLibrariesFullClr(result, "TestAppFullClr");
|
||||||
|
}
|
||||||
|
|
||||||
|
[WindowsOnlyFact]
|
||||||
|
public void PublishTestFullClr()
|
||||||
|
{
|
||||||
|
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestAppFullClr");
|
||||||
|
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||||
|
|
||||||
|
var publishCommand = new PublishCommand(testProject);
|
||||||
|
publishCommand.Execute().Should().Pass();
|
||||||
|
|
||||||
|
var result = TestExecutable(publishCommand.GetOutputDirectory().FullName, publishCommand.GetOutputExecutable(), string.Empty);
|
||||||
|
ValidateRuntimeLibraritesFullClr(result, "TestAppFullClr");
|
||||||
|
ValidateCompilationLibrariesFullClr(result, "TestAppFullClr");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidateRuntimeLibraritesFullClr(CommandResult result, string appname)
|
||||||
|
{
|
||||||
|
// entry assembly
|
||||||
|
result.Should().HaveStdOutContaining($"Runtime {appname}:{appname}");
|
||||||
|
// project dependency
|
||||||
|
result.Should().HaveStdOutContaining("Runtime DependencyContextValidator:DependencyContextValidator");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidateCompilationLibrariesFullClr(CommandResult result, string appname)
|
||||||
|
{
|
||||||
|
// entry assembly
|
||||||
|
result.Should().HaveStdOutContaining($"Compilation {appname}:{appname}.exe");
|
||||||
|
// project dependency
|
||||||
|
result.Should().HaveStdOutContaining("Compilation DependencyContextValidator:DependencyContextValidator.dll");
|
||||||
|
// system assembly
|
||||||
|
result.Should().HaveStdOutContaining("Compilation mscorlib:mscorlib.dll");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ValidateRuntimeLibrarites(CommandResult result, string appname)
|
||||||
|
{
|
||||||
|
// entry assembly
|
||||||
|
result.Should().HaveStdOutContaining($"Runtime {appname}:{appname}");
|
||||||
|
// project dependency
|
||||||
|
result.Should().HaveStdOutContaining("Runtime DependencyContextValidator:DependencyContextValidator");
|
||||||
|
// system assembly
|
||||||
|
result.Should().HaveStdOutContaining("Runtime System.Linq:System.Linq");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidateCompilationLibraries(CommandResult result, string appname)
|
||||||
|
{
|
||||||
|
// entry assembly
|
||||||
|
result.Should().HaveStdOutContaining($"Compilation {appname}:{appname}.dll");
|
||||||
|
// project dependency
|
||||||
|
result.Should().HaveStdOutContaining("Compilation DependencyContextValidator:DependencyContextValidator.dll");
|
||||||
|
// system assembly
|
||||||
|
result.Should().HaveStdOutContaining("Compilation System.Linq:System.Linq.dll");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,9 @@
|
||||||
"Microsoft.DotNet.Tools.Tests.Utilities": {
|
"Microsoft.DotNet.Tools.Tests.Utilities": {
|
||||||
"target": "project"
|
"target": "project"
|
||||||
},
|
},
|
||||||
|
"Microsoft.DotNet.Cli.Utils": {
|
||||||
|
"target": "project"
|
||||||
|
},
|
||||||
"FluentAssertions": "4.0.0",
|
"FluentAssertions": "4.0.0",
|
||||||
"moq.netcore": "4.4.0-beta8",
|
"moq.netcore": "4.4.0-beta8",
|
||||||
"xunit": "2.1.0",
|
"xunit": "2.1.0",
|
||||||
|
|
|
@ -147,26 +147,6 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
result.StdOut.Should().Contain("MyNamespace.Util");
|
result.StdOut.Should().Contain("MyNamespace.Util");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void EmbeddedDependencyContextIsValidOnBuild()
|
|
||||||
{
|
|
||||||
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestApp");
|
|
||||||
var testProject = Path.Combine(testProjectPath, "project.json");
|
|
||||||
|
|
||||||
var runCommand = new RunCommand(testProject);
|
|
||||||
runCommand.Execute().Should().Pass();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void DepsDependencyContextIsValidOnBuild()
|
|
||||||
{
|
|
||||||
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestAppDeps");
|
|
||||||
var testProject = Path.Combine(testProjectPath, "project.json");
|
|
||||||
|
|
||||||
var runCommand = new RunCommand(testProject);
|
|
||||||
runCommand.Execute().Should().Pass();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanSetOutputAssemblyNameForLibraries()
|
public void CanSetOutputAssemblyNameForLibraries()
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,6 +81,24 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
||||||
publishDir.Should().NotHaveFile("PortableAppWithNative.runtimeconfig.dev.json");
|
publishDir.Should().NotHaveFile("PortableAppWithNative.runtimeconfig.dev.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void RefsPublishTest()
|
||||||
|
{
|
||||||
|
TestInstance instance = TestAssetsManager.CreateTestInstance("PortableTests")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var publishCommand = new PublishCommand(Path.Combine(instance.TestRoot, "PortableAppCompilationContext"));
|
||||||
|
publishCommand.Execute().Should().Pass();
|
||||||
|
|
||||||
|
publishCommand.GetOutputDirectory(true).Should().HaveFile("PortableAppCompilationContext.dll");
|
||||||
|
|
||||||
|
var refsDirectory = new DirectoryInfo(Path.Combine(publishCommand.GetOutputDirectory(true).FullName, "refs"));
|
||||||
|
// Should have compilation time assemblies
|
||||||
|
refsDirectory.Should().HaveFile("System.IO.dll");
|
||||||
|
// Libraries in which lib==ref should be deduped
|
||||||
|
refsDirectory.Should().NotHaveFile("PortableAppCompilationContext.dll");
|
||||||
|
}
|
||||||
|
|
||||||
private DirectoryInfo Publish(TestInstance testInstance)
|
private DirectoryInfo Publish(TestInstance testInstance)
|
||||||
{
|
{
|
||||||
var publishCommand = new PublishCommand(Path.Combine(testInstance.TestRoot, "PortableAppWithNative"));
|
var publishCommand = new PublishCommand(Path.Combine(testInstance.TestRoot, "PortableAppWithNative"));
|
||||||
|
|
Loading…
Add table
Reference in a new issue