Test self-contained applications

This commit is contained in:
Mike Harder 2018-05-09 10:52:23 -07:00 committed by GitHub
parent ee710d3954
commit af8152f80e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 892 additions and 362 deletions

View File

@ -1,74 +0,0 @@
using AspNetCoreSdkTests.Templates;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Net;
namespace AspNetCoreSdkTests
{
[TestFixture]
public class FrameworkDependent
{
[Test]
[TestCaseSource(nameof(RestoreData))]
public void Restore(Template template)
{
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterRestore, template.ObjFilesAfterRestore);
}
[Test]
[TestCaseSource(nameof(BuildData))]
public void Build(Template template)
{
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterBuild, template.ObjFilesAfterBuild);
}
[Test]
[TestCaseSource(nameof(PublishData))]
public void Publish(Template template)
{
CollectionAssert.AreEquivalent(template.ExpectedFilesAfterPublish, template.FilesAfterPublish);
}
[Test]
[TestCaseSource(nameof(RunData))]
public void Run(Template template)
{
Assert.AreEqual(HttpStatusCode.OK, template.HttpResponseAfterRun.StatusCode);
Assert.AreEqual(HttpStatusCode.OK, template.HttpsResponseAfterRun.StatusCode);
}
[Test]
[TestCaseSource(nameof(ExecData))]
public void Exec(Template template)
{
Assert.AreEqual(HttpStatusCode.OK, template.HttpResponseAfterExec.StatusCode);
Assert.AreEqual(HttpStatusCode.OK, template.HttpsResponseAfterExec.StatusCode);
}
public static IEnumerable<Template> RestoreData = new[]
{
Template.GetInstance<ClassLibraryTemplate>(NuGetPackageSource.None),
Template.GetInstance<ConsoleApplicationTemplate>(NuGetPackageSource.None),
// Offline restore currently not supported for RazorClassLibrary template (https://github.com/aspnet/Universe/issues/1123)
Template.GetInstance<RazorClassLibraryTemplate>(NuGetPackageSource.NuGetOrg),
Template.GetInstance<WebTemplate>(NuGetPackageSource.None),
Template.GetInstance<RazorTemplate>(NuGetPackageSource.None),
Template.GetInstance<MvcTemplate>(NuGetPackageSource.None),
Template.GetInstance<AngularTemplate>(NuGetPackageSource.None),
Template.GetInstance<ReactTemplate>(NuGetPackageSource.None),
Template.GetInstance<ReactReduxTemplate>(NuGetPackageSource.None),
Template.GetInstance<WebApiTemplate>(NuGetPackageSource.None),
};
public static IEnumerable<Template> BuildData => RestoreData;
public static IEnumerable<Template> PublishData => RestoreData;
public static IEnumerable<Template> RunData = RestoreData.Where(t => t.Type == TemplateType.WebApplication);
public static IEnumerable<Template> ExecData => RunData;
}
}

View File

@ -0,0 +1,17 @@
namespace AspNetCoreSdkTests
{
// https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
public class RuntimeIdentifier
{
public static RuntimeIdentifier None = new RuntimeIdentifier() { Name = "none" };
public static RuntimeIdentifier Win_x64 = new RuntimeIdentifier() { Name = "win-x64" };
private RuntimeIdentifier() { }
public string Name { get; private set; }
public string RuntimeArgument => (this == None) ? string.Empty : $"--runtime {Name}";
public string Path => (this == None) ? string.Empty : Name;
public override string ToString() => Name;
}
}

View File

@ -1,31 +0,0 @@
using AspNetCoreSdkTests.Templates;
using NUnit.Framework;
using System.Collections.Generic;
namespace AspNetCoreSdkTests
{
[TestFixture]
public class SelfContained
{
[Test]
[TestCaseSource(nameof(RestoreData))]
public void Restore(Template template)
{
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterRestore, template.ObjFilesAfterRestore);
}
public static IEnumerable<Template> RestoreData = new[]
{
Template.GetInstance<ClassLibraryTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<ConsoleApplicationTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<RazorClassLibraryTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<WebTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<RazorTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<MvcTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<AngularTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<ReactTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<ReactReduxTemplate>(NuGetPackageSource.EnvironmentVariable),
Template.GetInstance<WebApiTemplate>(NuGetPackageSource.EnvironmentVariable),
};
}
}

View File

@ -0,0 +1,96 @@
using AspNetCoreSdkTests.Templates;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Net;
namespace AspNetCoreSdkTests
{
[TestFixture]
public class TemplateTests
{
[Test]
[TestCaseSource(nameof(RestoreData))]
public void Restore(Template template)
{
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterRestore, template.ObjFilesAfterRestore);
}
[Test]
[TestCaseSource(nameof(BuildData))]
public void Build(Template template)
{
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterBuild, template.ObjFilesAfterBuild);
CollectionAssert.AreEquivalent(template.ExpectedBinFilesAfterBuild, template.BinFilesAfterBuild);
}
[Test]
[TestCaseSource(nameof(PublishData))]
public void Publish(Template template)
{
CollectionAssert.AreEquivalent(template.ExpectedFilesAfterPublish, template.FilesAfterPublish);
}
[Test]
[TestCaseSource(nameof(RunData))]
public void Run(Template template)
{
Assert.AreEqual(HttpStatusCode.OK, template.HttpResponseAfterRun.StatusCode);
Assert.AreEqual(HttpStatusCode.OK, template.HttpsResponseAfterRun.StatusCode);
}
[Test]
[TestCaseSource(nameof(ExecData))]
public void Exec(Template template)
{
Assert.AreEqual(HttpStatusCode.OK, template.HttpResponseAfterExec.StatusCode);
Assert.AreEqual(HttpStatusCode.OK, template.HttpsResponseAfterExec.StatusCode);
}
public static IEnumerable<Template> RestoreData = new[]
{
// Framework-dependent
Template.GetInstance<ClassLibraryTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
Template.GetInstance<ConsoleApplicationTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
// Offline restore currently not supported for RazorClassLibrary template (https://github.com/aspnet/Universe/issues/1123)
Template.GetInstance<RazorClassLibraryTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.None),
Template.GetInstance<WebTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
Template.GetInstance<RazorTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
Template.GetInstance<MvcTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
Template.GetInstance<AngularTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
Template.GetInstance<ReactTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
Template.GetInstance<ReactReduxTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
Template.GetInstance<WebApiTemplate>(NuGetPackageSource.None, RuntimeIdentifier.None),
// Self-contained
// ClassLibrary does not require a package source, even for self-contained deployments
Template.GetInstance<ClassLibraryTemplate>(NuGetPackageSource.None, RuntimeIdentifier.Win_x64),
Template.GetInstance<ConsoleApplicationTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
// Offline restore currently not supported for RazorClassLibrary template (https://github.com/aspnet/Universe/issues/1123)
Template.GetInstance<RazorClassLibraryTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
Template.GetInstance<WebTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
Template.GetInstance<RazorTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
Template.GetInstance<MvcTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
Template.GetInstance<AngularTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
Template.GetInstance<ReactTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
Template.GetInstance<ReactReduxTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
Template.GetInstance<WebApiTemplate>(NuGetPackageSource.NuGetOrg, RuntimeIdentifier.Win_x64),
};
public static IEnumerable<Template> BuildData => RestoreData;
public static IEnumerable<Template> PublishData => BuildData;
public static IEnumerable<Template> RunData =
BuildData.
// Only interested in verifying web applications
Where(t => t.Type == TemplateType.WebApplication).
// "dotnet run" is only relevant for framework-dependent apps
Where(t => t.RuntimeIdentifier == RuntimeIdentifier.None);
public static IEnumerable<Template> ExecData =
PublishData.
// Only interested in verifying web applications
Where(t => t.Type == TemplateType.WebApplication);
}
}

View File

@ -10,7 +10,7 @@ namespace AspNetCoreSdkTests.Templates
public override string Name => "classlib";
public virtual string OutputPath { get; } = Path.Combine("Debug", "netstandard2.0");
public override string OutputPath => Path.Combine("Debug", "netstandard2.0", RuntimeIdentifier.Path);
public override TemplateType Type => TemplateType.ClassLibrary;

View File

@ -11,19 +11,275 @@ namespace AspNetCoreSdkTests.Templates
public override string Name => "console";
public override string OutputPath { get; } = Path.Combine("Debug", "netcoreapp2.1");
public override string OutputPath => Path.Combine("Debug", "netcoreapp2.1", RuntimeIdentifier.Path);
public override TemplateType Type => TemplateType.ConsoleApplication;
public override IEnumerable<string> ExpectedBinFilesAfterBuild => Enumerable.Concat(base.ExpectedBinFilesAfterBuild, new[]
{
$"{Name}.runtimeconfig.dev.json",
$"{Name}.runtimeconfig.json",
}.Select(p => Path.Combine(OutputPath, p)));
private IDictionary<RuntimeIdentifier, Func<IEnumerable<string>>> _additionalObjFilesAfterBuild =>
new Dictionary<RuntimeIdentifier, Func<IEnumerable<string>>>()
{
{ RuntimeIdentifier.None, () => Enumerable.Empty<string>() },
{ RuntimeIdentifier.Win_x64, () => new[]
{
Path.Combine("netcoreapp2.1", RuntimeIdentifier.Path, "host", $"{Name}.exe"),
}
}
};
public override IEnumerable<string> ExpectedFilesAfterPublish => Enumerable.Concat(base.ExpectedFilesAfterPublish, new[]
{
$"{Name}.runtimeconfig.json",
});
public override IEnumerable<string> ExpectedObjFilesAfterBuild =>
Enumerable.Concat(base.ExpectedObjFilesAfterBuild, _additionalObjFilesAfterBuild[RuntimeIdentifier]());
private IDictionary<RuntimeIdentifier, Func<IEnumerable<string>>> _additionalBinFilesAfterBuild =>
new Dictionary<RuntimeIdentifier, Func<IEnumerable<string>>>()
{
{ RuntimeIdentifier.None, () => new[]
{
$"{Name}.runtimeconfig.dev.json",
$"{Name}.runtimeconfig.json",
}.Select(p => Path.Combine(OutputPath, p))
},
{ RuntimeIdentifier.Win_x64, () => Enumerable.Concat(_additionalBinFilesAfterBuild[RuntimeIdentifier.None](), new[]
{
$"{Name}.exe",
"hostfxr.dll",
"hostpolicy.dll",
}.Select(p => Path.Combine(OutputPath, p)))
}
};
public override IEnumerable<string> ExpectedBinFilesAfterBuild =>
Enumerable.Concat(base.ExpectedBinFilesAfterBuild, _additionalBinFilesAfterBuild[RuntimeIdentifier]());
private IDictionary<RuntimeIdentifier, Func<IEnumerable<string>>> _additionalFilesAfterPublish =>
new Dictionary<RuntimeIdentifier, Func<IEnumerable<string>>>()
{
{ RuntimeIdentifier.None, () => new[]
{
$"{Name}.runtimeconfig.json",
}
},
{ RuntimeIdentifier.Win_x64, () => Enumerable.Concat(_additionalFilesAfterPublish[RuntimeIdentifier.None](), new[]
{
$"{Name}.exe",
"api-ms-win-core-console-l1-1-0.dll",
"api-ms-win-core-datetime-l1-1-0.dll",
"api-ms-win-core-debug-l1-1-0.dll",
"api-ms-win-core-errorhandling-l1-1-0.dll",
"api-ms-win-core-file-l1-1-0.dll",
"api-ms-win-core-file-l1-2-0.dll",
"api-ms-win-core-file-l2-1-0.dll",
"api-ms-win-core-handle-l1-1-0.dll",
"api-ms-win-core-heap-l1-1-0.dll",
"api-ms-win-core-interlocked-l1-1-0.dll",
"api-ms-win-core-libraryloader-l1-1-0.dll",
"api-ms-win-core-localization-l1-2-0.dll",
"api-ms-win-core-memory-l1-1-0.dll",
"api-ms-win-core-namedpipe-l1-1-0.dll",
"api-ms-win-core-processenvironment-l1-1-0.dll",
"api-ms-win-core-processthreads-l1-1-0.dll",
"api-ms-win-core-processthreads-l1-1-1.dll",
"api-ms-win-core-profile-l1-1-0.dll",
"api-ms-win-core-rtlsupport-l1-1-0.dll",
"api-ms-win-core-string-l1-1-0.dll",
"api-ms-win-core-synch-l1-1-0.dll",
"api-ms-win-core-synch-l1-2-0.dll",
"api-ms-win-core-sysinfo-l1-1-0.dll",
"api-ms-win-core-timezone-l1-1-0.dll",
"api-ms-win-core-util-l1-1-0.dll",
"api-ms-win-crt-conio-l1-1-0.dll",
"api-ms-win-crt-convert-l1-1-0.dll",
"api-ms-win-crt-environment-l1-1-0.dll",
"api-ms-win-crt-filesystem-l1-1-0.dll",
"api-ms-win-crt-heap-l1-1-0.dll",
"api-ms-win-crt-locale-l1-1-0.dll",
"api-ms-win-crt-math-l1-1-0.dll",
"api-ms-win-crt-multibyte-l1-1-0.dll",
"api-ms-win-crt-private-l1-1-0.dll",
"api-ms-win-crt-process-l1-1-0.dll",
"api-ms-win-crt-runtime-l1-1-0.dll",
"api-ms-win-crt-stdio-l1-1-0.dll",
"api-ms-win-crt-string-l1-1-0.dll",
"api-ms-win-crt-time-l1-1-0.dll",
"api-ms-win-crt-utility-l1-1-0.dll",
"clrcompression.dll",
"clretwrc.dll",
"clrjit.dll",
"coreclr.dll",
"dbgshim.dll",
"hostfxr.dll",
"hostpolicy.dll",
"Microsoft.CSharp.dll",
"Microsoft.DiaSymReader.Native.amd64.dll",
"Microsoft.VisualBasic.dll",
"Microsoft.Win32.Primitives.dll",
"Microsoft.Win32.Registry.dll",
"mscordaccore.dll",
"mscordaccore_amd64_amd64_4.6.26426.02.dll",
"mscordbi.dll",
"mscorlib.dll",
"mscorrc.debug.dll",
"mscorrc.dll",
"netstandard.dll",
"sos.dll",
"SOS.NETCore.dll",
"sos_amd64_amd64_4.6.26426.02.dll",
"System.AppContext.dll",
"System.Buffers.dll",
"System.Collections.Concurrent.dll",
"System.Collections.dll",
"System.Collections.Immutable.dll",
"System.Collections.NonGeneric.dll",
"System.Collections.Specialized.dll",
"System.ComponentModel.Annotations.dll",
"System.ComponentModel.DataAnnotations.dll",
"System.ComponentModel.dll",
"System.ComponentModel.EventBasedAsync.dll",
"System.ComponentModel.Primitives.dll",
"System.ComponentModel.TypeConverter.dll",
"System.Configuration.dll",
"System.Console.dll",
"System.Core.dll",
"System.Data.Common.dll",
"System.Data.dll",
"System.Diagnostics.Contracts.dll",
"System.Diagnostics.Debug.dll",
"System.Diagnostics.DiagnosticSource.dll",
"System.Diagnostics.FileVersionInfo.dll",
"System.Diagnostics.Process.dll",
"System.Diagnostics.StackTrace.dll",
"System.Diagnostics.TextWriterTraceListener.dll",
"System.Diagnostics.Tools.dll",
"System.Diagnostics.TraceSource.dll",
"System.Diagnostics.Tracing.dll",
"System.dll",
"System.Drawing.dll",
"System.Drawing.Primitives.dll",
"System.Dynamic.Runtime.dll",
"System.Globalization.Calendars.dll",
"System.Globalization.dll",
"System.Globalization.Extensions.dll",
"System.IO.Compression.Brotli.dll",
"System.IO.Compression.dll",
"System.IO.Compression.FileSystem.dll",
"System.IO.Compression.ZipFile.dll",
"System.IO.dll",
"System.IO.FileSystem.AccessControl.dll",
"System.IO.FileSystem.dll",
"System.IO.FileSystem.DriveInfo.dll",
"System.IO.FileSystem.Primitives.dll",
"System.IO.FileSystem.Watcher.dll",
"System.IO.IsolatedStorage.dll",
"System.IO.MemoryMappedFiles.dll",
"System.IO.Pipes.AccessControl.dll",
"System.IO.Pipes.dll",
"System.IO.UnmanagedMemoryStream.dll",
"System.Linq.dll",
"System.Linq.Expressions.dll",
"System.Linq.Parallel.dll",
"System.Linq.Queryable.dll",
"System.Memory.dll",
"System.Net.dll",
"System.Net.Http.dll",
"System.Net.HttpListener.dll",
"System.Net.Mail.dll",
"System.Net.NameResolution.dll",
"System.Net.NetworkInformation.dll",
"System.Net.Ping.dll",
"System.Net.Primitives.dll",
"System.Net.Requests.dll",
"System.Net.Security.dll",
"System.Net.ServicePoint.dll",
"System.Net.Sockets.dll",
"System.Net.WebClient.dll",
"System.Net.WebHeaderCollection.dll",
"System.Net.WebProxy.dll",
"System.Net.WebSockets.Client.dll",
"System.Net.WebSockets.dll",
"System.Numerics.dll",
"System.Numerics.Vectors.dll",
"System.ObjectModel.dll",
"System.Private.CoreLib.dll",
"System.Private.DataContractSerialization.dll",
"System.Private.Uri.dll",
"System.Private.Xml.dll",
"System.Private.Xml.Linq.dll",
"System.Reflection.DispatchProxy.dll",
"System.Reflection.dll",
"System.Reflection.Emit.dll",
"System.Reflection.Emit.ILGeneration.dll",
"System.Reflection.Emit.Lightweight.dll",
"System.Reflection.Extensions.dll",
"System.Reflection.Metadata.dll",
"System.Reflection.Primitives.dll",
"System.Reflection.TypeExtensions.dll",
"System.Resources.Reader.dll",
"System.Resources.ResourceManager.dll",
"System.Resources.Writer.dll",
"System.Runtime.CompilerServices.VisualC.dll",
"System.Runtime.dll",
"System.Runtime.Extensions.dll",
"System.Runtime.Handles.dll",
"System.Runtime.InteropServices.dll",
"System.Runtime.InteropServices.RuntimeInformation.dll",
"System.Runtime.InteropServices.WindowsRuntime.dll",
"System.Runtime.Loader.dll",
"System.Runtime.Numerics.dll",
"System.Runtime.Serialization.dll",
"System.Runtime.Serialization.Formatters.dll",
"System.Runtime.Serialization.Json.dll",
"System.Runtime.Serialization.Primitives.dll",
"System.Runtime.Serialization.Xml.dll",
"System.Security.AccessControl.dll",
"System.Security.Claims.dll",
"System.Security.Cryptography.Algorithms.dll",
"System.Security.Cryptography.Cng.dll",
"System.Security.Cryptography.Csp.dll",
"System.Security.Cryptography.Encoding.dll",
"System.Security.Cryptography.OpenSsl.dll",
"System.Security.Cryptography.Primitives.dll",
"System.Security.Cryptography.X509Certificates.dll",
"System.Security.dll",
"System.Security.Principal.dll",
"System.Security.Principal.Windows.dll",
"System.Security.SecureString.dll",
"System.ServiceModel.Web.dll",
"System.ServiceProcess.dll",
"System.Text.Encoding.dll",
"System.Text.Encoding.Extensions.dll",
"System.Text.RegularExpressions.dll",
"System.Threading.dll",
"System.Threading.Overlapped.dll",
"System.Threading.Tasks.Dataflow.dll",
"System.Threading.Tasks.dll",
"System.Threading.Tasks.Extensions.dll",
"System.Threading.Tasks.Parallel.dll",
"System.Threading.Thread.dll",
"System.Threading.ThreadPool.dll",
"System.Threading.Timer.dll",
"System.Transactions.dll",
"System.Transactions.Local.dll",
"System.ValueTuple.dll",
"System.Web.dll",
"System.Web.HttpUtility.dll",
"System.Windows.dll",
"System.Xml.dll",
"System.Xml.Linq.dll",
"System.Xml.ReaderWriter.dll",
"System.Xml.Serialization.dll",
"System.Xml.XDocument.dll",
"System.Xml.XmlDocument.dll",
"System.Xml.XmlSerializer.dll",
"System.Xml.XPath.dll",
"System.Xml.XPath.XDocument.dll",
"ucrtbase.dll",
"WindowsBase.dll",
})
}
};
public override IEnumerable<string> ExpectedFilesAfterPublish =>
Enumerable.Concat(base.ExpectedFilesAfterPublish, _additionalFilesAfterPublish[RuntimeIdentifier]());
}
}

View File

@ -1,34 +1,47 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AspNetCoreSdkTests.Templates
{
public abstract class RazorApplicationBaseTemplate : RazorBaseTemplate
public abstract class RazorApplicationBaseTemplate : WebTemplate
{
protected abstract string RazorPath { get; }
private IDictionary<RuntimeIdentifier, Func<IEnumerable<string>>> _additionalObjFilesAfterBuild =>
new Dictionary<RuntimeIdentifier, Func<IEnumerable<string>>>()
{
{ RuntimeIdentifier.None, () => new[]
{
Path.Combine("Razor", RazorPath, "_ViewImports.g.cshtml.cs"),
}.Select(p => Path.Combine(OutputPath, p))
},
{ RuntimeIdentifier.Win_x64, () => Enumerable.Concat(_additionalObjFilesAfterBuild[RuntimeIdentifier.None](), new[]
{
Path.Combine("netcoreapp2.1", RuntimeIdentifier.Path, "host", $"{Name}.exe"),
})
}
};
public override string OutputPath { get; } = Path.Combine("Debug", "netcoreapp2.1");
public override IEnumerable<string> ExpectedObjFilesAfterBuild =>
base.ExpectedObjFilesAfterBuild
.Concat(RazorUtil.GetExpectedObjFilesAfterBuild(this))
.Concat(_additionalObjFilesAfterBuild[RuntimeIdentifier]())
// Some files are duplicated in WebTemplate and RazorUtil, since they are needed by RazorClassLibraryTemplate
.Distinct();
public override TemplateType Type => TemplateType.WebApplication;
public override IEnumerable<string> ExpectedBinFilesAfterBuild =>
base.ExpectedBinFilesAfterBuild
.Concat(RazorUtil.GetExpectedBinFilesAfterBuild(this));
public override IEnumerable<string> ExpectedObjFilesAfterBuild => Enumerable.Concat(base.ExpectedObjFilesAfterBuild, new[]
{
Path.Combine("Razor", RazorPath, "_ViewImports.g.cshtml.cs"),
}.Select(p => Path.Combine(OutputPath, p)));
public override IEnumerable<string> ExpectedBinFilesAfterBuild => Enumerable.Concat(base.ExpectedBinFilesAfterBuild, new[]
{
$"{Name}.runtimeconfig.dev.json",
$"{Name}.runtimeconfig.json",
}.Select(p => Path.Combine(OutputPath, p)));
public override IEnumerable<string> ExpectedFilesAfterPublish => Enumerable.Concat(base.ExpectedFilesAfterPublish, new[]
{
"appsettings.Development.json",
"appsettings.json",
$"{Name}.runtimeconfig.json",
"web.config",
});
public override IEnumerable<string> ExpectedFilesAfterPublish =>
base.ExpectedFilesAfterPublish
.Concat(RazorUtil.GetExpectedFilesAfterPublish(this))
.Concat(new[]
{
"appsettings.Development.json",
"appsettings.json",
});
}
}

View File

@ -1,34 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AspNetCoreSdkTests.Templates
{
public abstract class RazorBaseTemplate : ClassLibraryTemplate
{
public override IEnumerable<string> ExpectedObjFilesAfterBuild => Enumerable.Concat(base.ExpectedObjFilesAfterBuild, new[]
{
$"{Name}.RazorAssemblyInfo.cache",
$"{Name}.RazorAssemblyInfo.cs",
$"{Name}.RazorCoreGenerate.cache",
$"{Name}.RazorTargetAssemblyInfo.cache",
$"{Name}.RazorTargetAssemblyInfo.cs",
$"{Name}.TagHelpers.input.cache",
$"{Name}.TagHelpers.output.cache",
$"{Name}.Views.dll",
$"{Name}.Views.pdb",
}.Select(p => Path.Combine(OutputPath, p)));
public override IEnumerable<string> ExpectedBinFilesAfterBuild => Enumerable.Concat(base.ExpectedBinFilesAfterBuild, new[]
{
$"{Name}.Views.dll",
$"{Name}.Views.pdb",
}.Select(p => Path.Combine(OutputPath, p)));
public override IEnumerable<string> ExpectedFilesAfterPublish => Enumerable.Concat(base.ExpectedFilesAfterPublish, new[]
{
$"{Name}.Views.dll",
$"{Name}.Views.pdb",
});
}
}

View File

@ -1,142 +1,149 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AspNetCoreSdkTests.Templates
{
public class RazorClassLibraryTemplate : RazorBaseTemplate
public class RazorClassLibraryTemplate : ClassLibraryTemplate
{
public RazorClassLibraryTemplate() { }
public override string Name => "razorclasslib";
public override IEnumerable<string> ExpectedObjFilesAfterBuild => Enumerable.Concat(base.ExpectedObjFilesAfterBuild, new[]
{
Path.Combine("Razor", "Areas", "MyFeature", "Pages", "Page1.g.cshtml.cs"),
}.Select(p => Path.Combine(OutputPath, p)));
public override IEnumerable<string> ExpectedObjFilesAfterBuild =>
base.ExpectedObjFilesAfterBuild
.Concat(RazorUtil.GetExpectedObjFilesAfterBuild(this))
.Concat(new[]
{
Path.Combine("Razor", "Areas", "MyFeature", "Pages", "Page1.g.cshtml.cs"),
}.Select(p => Path.Combine(OutputPath, p)));
// We set PreserveCompilationContext=true for all project types in the Razor.Sdk. This results in an refs directory to be created
// in the build output directory which is undesirable. We should consider setting PreserveCompilationContext=true only if the
// app's an executable.
// https://github.com/aspnet/Razor/issues/2308
public override IEnumerable<string> ExpectedBinFilesAfterBuild => Enumerable.Concat(base.ExpectedBinFilesAfterBuild, new[]
{
Path.Combine("refs", "Microsoft.Win32.Primitives.dll"),
Path.Combine("refs", "mscorlib.dll"),
Path.Combine("refs", "netstandard.dll"),
Path.Combine("refs", "System.AppContext.dll"),
Path.Combine("refs", "System.Collections.Concurrent.dll"),
Path.Combine("refs", "System.Collections.dll"),
Path.Combine("refs", "System.Collections.NonGeneric.dll"),
Path.Combine("refs", "System.Collections.Specialized.dll"),
Path.Combine("refs", "System.ComponentModel.Composition.dll"),
Path.Combine("refs", "System.ComponentModel.dll"),
Path.Combine("refs", "System.ComponentModel.EventBasedAsync.dll"),
Path.Combine("refs", "System.ComponentModel.Primitives.dll"),
Path.Combine("refs", "System.ComponentModel.TypeConverter.dll"),
Path.Combine("refs", "System.Console.dll"),
Path.Combine("refs", "System.Core.dll"),
Path.Combine("refs", "System.Data.Common.dll"),
Path.Combine("refs", "System.Data.dll"),
Path.Combine("refs", "System.Diagnostics.Contracts.dll"),
Path.Combine("refs", "System.Diagnostics.Debug.dll"),
Path.Combine("refs", "System.Diagnostics.FileVersionInfo.dll"),
Path.Combine("refs", "System.Diagnostics.Process.dll"),
Path.Combine("refs", "System.Diagnostics.StackTrace.dll"),
Path.Combine("refs", "System.Diagnostics.TextWriterTraceListener.dll"),
Path.Combine("refs", "System.Diagnostics.Tools.dll"),
Path.Combine("refs", "System.Diagnostics.TraceSource.dll"),
Path.Combine("refs", "System.Diagnostics.Tracing.dll"),
Path.Combine("refs", "System.dll"),
Path.Combine("refs", "System.Drawing.dll"),
Path.Combine("refs", "System.Drawing.Primitives.dll"),
Path.Combine("refs", "System.Dynamic.Runtime.dll"),
Path.Combine("refs", "System.Globalization.Calendars.dll"),
Path.Combine("refs", "System.Globalization.dll"),
Path.Combine("refs", "System.Globalization.Extensions.dll"),
Path.Combine("refs", "System.IO.Compression.dll"),
Path.Combine("refs", "System.IO.Compression.FileSystem.dll"),
Path.Combine("refs", "System.IO.Compression.ZipFile.dll"),
Path.Combine("refs", "System.IO.dll"),
Path.Combine("refs", "System.IO.FileSystem.dll"),
Path.Combine("refs", "System.IO.FileSystem.DriveInfo.dll"),
Path.Combine("refs", "System.IO.FileSystem.Primitives.dll"),
Path.Combine("refs", "System.IO.FileSystem.Watcher.dll"),
Path.Combine("refs", "System.IO.IsolatedStorage.dll"),
Path.Combine("refs", "System.IO.MemoryMappedFiles.dll"),
Path.Combine("refs", "System.IO.Pipes.dll"),
Path.Combine("refs", "System.IO.UnmanagedMemoryStream.dll"),
Path.Combine("refs", "System.Linq.dll"),
Path.Combine("refs", "System.Linq.Expressions.dll"),
Path.Combine("refs", "System.Linq.Parallel.dll"),
Path.Combine("refs", "System.Linq.Queryable.dll"),
Path.Combine("refs", "System.Net.dll"),
Path.Combine("refs", "System.Net.Http.dll"),
Path.Combine("refs", "System.Net.NameResolution.dll"),
Path.Combine("refs", "System.Net.NetworkInformation.dll"),
Path.Combine("refs", "System.Net.Ping.dll"),
Path.Combine("refs", "System.Net.Primitives.dll"),
Path.Combine("refs", "System.Net.Requests.dll"),
Path.Combine("refs", "System.Net.Security.dll"),
Path.Combine("refs", "System.Net.Sockets.dll"),
Path.Combine("refs", "System.Net.WebHeaderCollection.dll"),
Path.Combine("refs", "System.Net.WebSockets.Client.dll"),
Path.Combine("refs", "System.Net.WebSockets.dll"),
Path.Combine("refs", "System.Numerics.dll"),
Path.Combine("refs", "System.ObjectModel.dll"),
Path.Combine("refs", "System.Reflection.dll"),
Path.Combine("refs", "System.Reflection.Extensions.dll"),
Path.Combine("refs", "System.Reflection.Primitives.dll"),
Path.Combine("refs", "System.Resources.Reader.dll"),
Path.Combine("refs", "System.Resources.ResourceManager.dll"),
Path.Combine("refs", "System.Resources.Writer.dll"),
Path.Combine("refs", "System.Runtime.CompilerServices.VisualC.dll"),
Path.Combine("refs", "System.Runtime.dll"),
Path.Combine("refs", "System.Runtime.Extensions.dll"),
Path.Combine("refs", "System.Runtime.Handles.dll"),
Path.Combine("refs", "System.Runtime.InteropServices.dll"),
Path.Combine("refs", "System.Runtime.InteropServices.RuntimeInformation.dll"),
Path.Combine("refs", "System.Runtime.Numerics.dll"),
Path.Combine("refs", "System.Runtime.Serialization.dll"),
Path.Combine("refs", "System.Runtime.Serialization.Formatters.dll"),
Path.Combine("refs", "System.Runtime.Serialization.Json.dll"),
Path.Combine("refs", "System.Runtime.Serialization.Primitives.dll"),
Path.Combine("refs", "System.Runtime.Serialization.Xml.dll"),
Path.Combine("refs", "System.Security.Claims.dll"),
Path.Combine("refs", "System.Security.Cryptography.Algorithms.dll"),
Path.Combine("refs", "System.Security.Cryptography.Csp.dll"),
Path.Combine("refs", "System.Security.Cryptography.Encoding.dll"),
Path.Combine("refs", "System.Security.Cryptography.Primitives.dll"),
Path.Combine("refs", "System.Security.Cryptography.X509Certificates.dll"),
Path.Combine("refs", "System.Security.Principal.dll"),
Path.Combine("refs", "System.Security.SecureString.dll"),
Path.Combine("refs", "System.ServiceModel.Web.dll"),
Path.Combine("refs", "System.Text.Encoding.dll"),
Path.Combine("refs", "System.Text.Encoding.Extensions.dll"),
Path.Combine("refs", "System.Text.RegularExpressions.dll"),
Path.Combine("refs", "System.Threading.dll"),
Path.Combine("refs", "System.Threading.Overlapped.dll"),
Path.Combine("refs", "System.Threading.Tasks.dll"),
Path.Combine("refs", "System.Threading.Tasks.Parallel.dll"),
Path.Combine("refs", "System.Threading.Thread.dll"),
Path.Combine("refs", "System.Threading.ThreadPool.dll"),
Path.Combine("refs", "System.Threading.Timer.dll"),
Path.Combine("refs", "System.Transactions.dll"),
Path.Combine("refs", "System.ValueTuple.dll"),
Path.Combine("refs", "System.Web.dll"),
Path.Combine("refs", "System.Windows.dll"),
Path.Combine("refs", "System.Xml.dll"),
Path.Combine("refs", "System.Xml.Linq.dll"),
Path.Combine("refs", "System.Xml.ReaderWriter.dll"),
Path.Combine("refs", "System.Xml.Serialization.dll"),
Path.Combine("refs", "System.Xml.XDocument.dll"),
Path.Combine("refs", "System.Xml.XmlDocument.dll"),
Path.Combine("refs", "System.Xml.XmlSerializer.dll"),
Path.Combine("refs", "System.Xml.XPath.dll"),
Path.Combine("refs", "System.Xml.XPath.XDocument.dll"),
}.Select(p => Path.Combine(OutputPath, p)));
public override IEnumerable<string> ExpectedBinFilesAfterBuild =>
base.ExpectedBinFilesAfterBuild
.Concat(RazorUtil.GetExpectedBinFilesAfterBuild(this))
.Concat(new[]
{
Path.Combine("refs", "Microsoft.Win32.Primitives.dll"),
Path.Combine("refs", "mscorlib.dll"),
Path.Combine("refs", "netstandard.dll"),
Path.Combine("refs", "System.AppContext.dll"),
Path.Combine("refs", "System.Collections.Concurrent.dll"),
Path.Combine("refs", "System.Collections.dll"),
Path.Combine("refs", "System.Collections.NonGeneric.dll"),
Path.Combine("refs", "System.Collections.Specialized.dll"),
Path.Combine("refs", "System.ComponentModel.Composition.dll"),
Path.Combine("refs", "System.ComponentModel.dll"),
Path.Combine("refs", "System.ComponentModel.EventBasedAsync.dll"),
Path.Combine("refs", "System.ComponentModel.Primitives.dll"),
Path.Combine("refs", "System.ComponentModel.TypeConverter.dll"),
Path.Combine("refs", "System.Console.dll"),
Path.Combine("refs", "System.Core.dll"),
Path.Combine("refs", "System.Data.Common.dll"),
Path.Combine("refs", "System.Data.dll"),
Path.Combine("refs", "System.Diagnostics.Contracts.dll"),
Path.Combine("refs", "System.Diagnostics.Debug.dll"),
Path.Combine("refs", "System.Diagnostics.FileVersionInfo.dll"),
Path.Combine("refs", "System.Diagnostics.Process.dll"),
Path.Combine("refs", "System.Diagnostics.StackTrace.dll"),
Path.Combine("refs", "System.Diagnostics.TextWriterTraceListener.dll"),
Path.Combine("refs", "System.Diagnostics.Tools.dll"),
Path.Combine("refs", "System.Diagnostics.TraceSource.dll"),
Path.Combine("refs", "System.Diagnostics.Tracing.dll"),
Path.Combine("refs", "System.dll"),
Path.Combine("refs", "System.Drawing.dll"),
Path.Combine("refs", "System.Drawing.Primitives.dll"),
Path.Combine("refs", "System.Dynamic.Runtime.dll"),
Path.Combine("refs", "System.Globalization.Calendars.dll"),
Path.Combine("refs", "System.Globalization.dll"),
Path.Combine("refs", "System.Globalization.Extensions.dll"),
Path.Combine("refs", "System.IO.Compression.dll"),
Path.Combine("refs", "System.IO.Compression.FileSystem.dll"),
Path.Combine("refs", "System.IO.Compression.ZipFile.dll"),
Path.Combine("refs", "System.IO.dll"),
Path.Combine("refs", "System.IO.FileSystem.dll"),
Path.Combine("refs", "System.IO.FileSystem.DriveInfo.dll"),
Path.Combine("refs", "System.IO.FileSystem.Primitives.dll"),
Path.Combine("refs", "System.IO.FileSystem.Watcher.dll"),
Path.Combine("refs", "System.IO.IsolatedStorage.dll"),
Path.Combine("refs", "System.IO.MemoryMappedFiles.dll"),
Path.Combine("refs", "System.IO.Pipes.dll"),
Path.Combine("refs", "System.IO.UnmanagedMemoryStream.dll"),
Path.Combine("refs", "System.Linq.dll"),
Path.Combine("refs", "System.Linq.Expressions.dll"),
Path.Combine("refs", "System.Linq.Parallel.dll"),
Path.Combine("refs", "System.Linq.Queryable.dll"),
Path.Combine("refs", "System.Net.dll"),
Path.Combine("refs", "System.Net.Http.dll"),
Path.Combine("refs", "System.Net.NameResolution.dll"),
Path.Combine("refs", "System.Net.NetworkInformation.dll"),
Path.Combine("refs", "System.Net.Ping.dll"),
Path.Combine("refs", "System.Net.Primitives.dll"),
Path.Combine("refs", "System.Net.Requests.dll"),
Path.Combine("refs", "System.Net.Security.dll"),
Path.Combine("refs", "System.Net.Sockets.dll"),
Path.Combine("refs", "System.Net.WebHeaderCollection.dll"),
Path.Combine("refs", "System.Net.WebSockets.Client.dll"),
Path.Combine("refs", "System.Net.WebSockets.dll"),
Path.Combine("refs", "System.Numerics.dll"),
Path.Combine("refs", "System.ObjectModel.dll"),
Path.Combine("refs", "System.Reflection.dll"),
Path.Combine("refs", "System.Reflection.Extensions.dll"),
Path.Combine("refs", "System.Reflection.Primitives.dll"),
Path.Combine("refs", "System.Resources.Reader.dll"),
Path.Combine("refs", "System.Resources.ResourceManager.dll"),
Path.Combine("refs", "System.Resources.Writer.dll"),
Path.Combine("refs", "System.Runtime.CompilerServices.VisualC.dll"),
Path.Combine("refs", "System.Runtime.dll"),
Path.Combine("refs", "System.Runtime.Extensions.dll"),
Path.Combine("refs", "System.Runtime.Handles.dll"),
Path.Combine("refs", "System.Runtime.InteropServices.dll"),
Path.Combine("refs", "System.Runtime.InteropServices.RuntimeInformation.dll"),
Path.Combine("refs", "System.Runtime.Numerics.dll"),
Path.Combine("refs", "System.Runtime.Serialization.dll"),
Path.Combine("refs", "System.Runtime.Serialization.Formatters.dll"),
Path.Combine("refs", "System.Runtime.Serialization.Json.dll"),
Path.Combine("refs", "System.Runtime.Serialization.Primitives.dll"),
Path.Combine("refs", "System.Runtime.Serialization.Xml.dll"),
Path.Combine("refs", "System.Security.Claims.dll"),
Path.Combine("refs", "System.Security.Cryptography.Algorithms.dll"),
Path.Combine("refs", "System.Security.Cryptography.Csp.dll"),
Path.Combine("refs", "System.Security.Cryptography.Encoding.dll"),
Path.Combine("refs", "System.Security.Cryptography.Primitives.dll"),
Path.Combine("refs", "System.Security.Cryptography.X509Certificates.dll"),
Path.Combine("refs", "System.Security.Principal.dll"),
Path.Combine("refs", "System.Security.SecureString.dll"),
Path.Combine("refs", "System.ServiceModel.Web.dll"),
Path.Combine("refs", "System.Text.Encoding.dll"),
Path.Combine("refs", "System.Text.Encoding.Extensions.dll"),
Path.Combine("refs", "System.Text.RegularExpressions.dll"),
Path.Combine("refs", "System.Threading.dll"),
Path.Combine("refs", "System.Threading.Overlapped.dll"),
Path.Combine("refs", "System.Threading.Tasks.dll"),
Path.Combine("refs", "System.Threading.Tasks.Parallel.dll"),
Path.Combine("refs", "System.Threading.Thread.dll"),
Path.Combine("refs", "System.Threading.ThreadPool.dll"),
Path.Combine("refs", "System.Threading.Timer.dll"),
Path.Combine("refs", "System.Transactions.dll"),
Path.Combine("refs", "System.ValueTuple.dll"),
Path.Combine("refs", "System.Web.dll"),
Path.Combine("refs", "System.Windows.dll"),
Path.Combine("refs", "System.Xml.dll"),
Path.Combine("refs", "System.Xml.Linq.dll"),
Path.Combine("refs", "System.Xml.ReaderWriter.dll"),
Path.Combine("refs", "System.Xml.Serialization.dll"),
Path.Combine("refs", "System.Xml.XDocument.dll"),
Path.Combine("refs", "System.Xml.XmlDocument.dll"),
Path.Combine("refs", "System.Xml.XmlSerializer.dll"),
Path.Combine("refs", "System.Xml.XPath.dll"),
Path.Combine("refs", "System.Xml.XPath.XDocument.dll"),
}.Select(p => Path.Combine(OutputPath, p)));
public override IEnumerable<string> ExpectedFilesAfterPublish => Enumerable.Concat(base.ExpectedFilesAfterPublish, new[]
private IEnumerable<string> _commonAdditionalFilesAfterPublish = new[]
{
"Microsoft.AspNetCore.Antiforgery.dll",
"Microsoft.AspNetCore.Authentication.Abstractions.dll",
@ -203,41 +210,6 @@ namespace AspNetCoreSdkTests.Templates
"Microsoft.Win32.Registry.dll",
"Newtonsoft.Json.Bson.dll",
"Newtonsoft.Json.dll",
Path.Combine("runtimes", "debian.8-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "fedora.23-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "fedora.24-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "opensuse.13.2-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "opensuse.42.1-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "osx", "lib", "netstandard1.6", "System.Security.Cryptography.Algorithms.dll"),
Path.Combine("runtimes", "osx.10.10-x64", "native", "System.Security.Cryptography.Native.Apple.dylib"),
Path.Combine("runtimes", "osx.10.10-x64", "native", "System.Security.Cryptography.Native.OpenSsl.dylib"),
Path.Combine("runtimes", "rhel.7-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "ubuntu.14.04-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "ubuntu.16.04-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "ubuntu.16.10-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.1", "System.Runtime.InteropServices.RuntimeInformation.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.Diagnostics.FileVersionInfo.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.IO.Compression.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.Security.Cryptography.Csp.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.Security.Cryptography.Encoding.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.Text.Encoding.CodePages.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.6", "System.Security.Cryptography.Algorithms.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.6", "System.Security.Cryptography.OpenSsl.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.6", "System.Security.Cryptography.X509Certificates.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard2.0", "Microsoft.Win32.Registry.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.1", "System.Runtime.InteropServices.RuntimeInformation.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Diagnostics.FileVersionInfo.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.IO.Compression.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Security.AccessControl.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Security.Cryptography.Csp.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Security.Cryptography.Encoding.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Security.Principal.Windows.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Text.Encoding.CodePages.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.6", "System.Security.Cryptography.Algorithms.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.6", "System.Security.Cryptography.Cng.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.6", "System.Security.Cryptography.X509Certificates.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard2.0", "Microsoft.Win32.Registry.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard2.0", "System.Security.Cryptography.Pkcs.dll"),
"System.AppContext.dll",
"System.Buffers.dll",
"System.Collections.Concurrent.dll",
@ -279,6 +251,88 @@ namespace AspNetCoreSdkTests.Templates
"System.Xml.XmlDocument.dll",
"System.Xml.XPath.dll",
"System.Xml.XPath.XDocument.dll",
});
};
private IDictionary<RuntimeIdentifier, Func<IEnumerable<string>>> _additionalFilesAfterPublish =>
new Dictionary<RuntimeIdentifier, Func<IEnumerable<string>>>()
{
{ RuntimeIdentifier.None, () => Enumerable.Concat(_commonAdditionalFilesAfterPublish, new[]
{
Path.Combine("runtimes", "debian.8-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "fedora.23-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "fedora.24-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "opensuse.13.2-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "opensuse.42.1-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "osx", "lib", "netstandard1.6", "System.Security.Cryptography.Algorithms.dll"),
Path.Combine("runtimes", "osx.10.10-x64", "native", "System.Security.Cryptography.Native.Apple.dylib"),
Path.Combine("runtimes", "osx.10.10-x64", "native", "System.Security.Cryptography.Native.OpenSsl.dylib"),
Path.Combine("runtimes", "rhel.7-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "ubuntu.14.04-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "ubuntu.16.04-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "ubuntu.16.10-x64", "native", "System.Security.Cryptography.Native.OpenSsl.so"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.1", "System.Runtime.InteropServices.RuntimeInformation.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.Diagnostics.FileVersionInfo.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.IO.Compression.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.Security.Cryptography.Csp.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.Security.Cryptography.Encoding.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.3", "System.Text.Encoding.CodePages.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.6", "System.Security.Cryptography.Algorithms.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.6", "System.Security.Cryptography.OpenSsl.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard1.6", "System.Security.Cryptography.X509Certificates.dll"),
Path.Combine("runtimes", "unix", "lib", "netstandard2.0", "Microsoft.Win32.Registry.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.1", "System.Runtime.InteropServices.RuntimeInformation.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Diagnostics.FileVersionInfo.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.IO.Compression.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Security.AccessControl.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Security.Cryptography.Csp.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Security.Cryptography.Encoding.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Security.Principal.Windows.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.3", "System.Text.Encoding.CodePages.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.6", "System.Security.Cryptography.Algorithms.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.6", "System.Security.Cryptography.Cng.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard1.6", "System.Security.Cryptography.X509Certificates.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard2.0", "Microsoft.Win32.Registry.dll"),
Path.Combine("runtimes", "win", "lib", "netstandard2.0", "System.Security.Cryptography.Pkcs.dll"),
})
},
{ RuntimeIdentifier.Win_x64, () => Enumerable.Concat(_commonAdditionalFilesAfterPublish, new[]
{
"System.Collections.dll",
"System.Console.dll",
"System.Diagnostics.Debug.dll",
"System.Diagnostics.FileVersionInfo.dll",
"System.Diagnostics.Tools.dll",
"System.Diagnostics.Tracing.dll",
"System.Globalization.Calendars.dll",
"System.Globalization.dll",
"System.IO.Compression.dll",
"System.IO.dll",
"System.IO.FileSystem.dll",
"System.Reflection.dll",
"System.Reflection.Extensions.dll",
"System.Reflection.Primitives.dll",
"System.Resources.ResourceManager.dll",
"System.Runtime.dll",
"System.Runtime.Extensions.dll",
"System.Runtime.Handles.dll",
"System.Runtime.InteropServices.dll",
"System.Runtime.InteropServices.RuntimeInformation.dll",
"System.Security.Cryptography.Algorithms.dll",
"System.Security.Cryptography.Csp.dll",
"System.Security.Cryptography.Encoding.dll",
"System.Security.Cryptography.X509Certificates.dll",
"System.Text.Encoding.CodePages.dll",
"System.Text.Encoding.dll",
"System.Text.Encoding.Extensions.dll",
"System.Threading.Overlapped.dll",
"System.Threading.Tasks.dll",
})
}
};
public override IEnumerable<string> ExpectedFilesAfterPublish =>
base.ExpectedFilesAfterPublish
.Concat(RazorUtil.GetExpectedFilesAfterPublish(this))
.Concat(_additionalFilesAfterPublish[RuntimeIdentifier]());
}
}

View File

@ -0,0 +1,34 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AspNetCoreSdkTests.Templates
{
public static class RazorUtil
{
public static IEnumerable<string> GetExpectedObjFilesAfterBuild(Template template) => new[]
{
$"{template.Name}.RazorAssemblyInfo.cache",
$"{template.Name}.RazorAssemblyInfo.cs",
$"{template.Name}.RazorCoreGenerate.cache",
$"{template.Name}.RazorTargetAssemblyInfo.cache",
$"{template.Name}.RazorTargetAssemblyInfo.cs",
$"{template.Name}.TagHelpers.input.cache",
$"{template.Name}.TagHelpers.output.cache",
$"{template.Name}.Views.dll",
$"{template.Name}.Views.pdb",
}.Select(p => Path.Combine(template.OutputPath, p));
public static IEnumerable<string> GetExpectedBinFilesAfterBuild(Template template) => new[]
{
$"{template.Name}.Views.dll",
$"{template.Name}.Views.pdb",
}.Select(p => Path.Combine(template.OutputPath, p));
public static IEnumerable<string> GetExpectedFilesAfterPublish(Template template) => new[]
{
$"{template.Name}.Views.dll",
$"{template.Name}.Views.pdb",
};
}
}

View File

@ -21,11 +21,13 @@ namespace AspNetCoreSdkTests.Templates
ServerCertificateCustomValidationCallback = (m, c, ch, p) => true
});
private static ConcurrentDictionary<(Type, NuGetPackageSource), Template> _templates = new ConcurrentDictionary<(Type, NuGetPackageSource), Template>();
private static ConcurrentDictionary<(Type Type, NuGetPackageSource NuGetPackageSource, RuntimeIdentifier RuntimeIdentifier), Template> _templates =
new ConcurrentDictionary<(Type Type, NuGetPackageSource NuGetPackageSource, RuntimeIdentifier RuntimeIdentifier), Template>();
public static T GetInstance<T>(NuGetPackageSource nuGetPackageSource) where T : Template, new()
public static T GetInstance<T>(NuGetPackageSource nuGetPackageSource, RuntimeIdentifier runtimeIdentifier) where T : Template, new()
{
return (T)_templates.GetOrAdd((typeof(T), nuGetPackageSource), (k) => new T() { NuGetPackageSource = nuGetPackageSource });
return (T)_templates.GetOrAdd((typeof(T), nuGetPackageSource, runtimeIdentifier),
(k) => new T() { NuGetPackageSource = nuGetPackageSource, RuntimeIdentifier = runtimeIdentifier });
}
private Lazy<IEnumerable<string>> _objFilesAfterRestore;
@ -35,6 +37,7 @@ namespace AspNetCoreSdkTests.Templates
private Lazy<(HttpResponseMessage Http, HttpResponseMessage Https)> _httpResponsesAfterExec;
public NuGetPackageSource NuGetPackageSource { get; private set; }
public RuntimeIdentifier RuntimeIdentifier { get; private set; }
protected Template()
{
@ -54,11 +57,12 @@ namespace AspNetCoreSdkTests.Templates
GetHttpResponsesAfterExec, LazyThreadSafetyMode.ExecutionAndPublication);
}
public override string ToString() => $"{Name},{NuGetPackageSource}";
public override string ToString() => $"{Name}, source: {NuGetPackageSource}, rid: {RuntimeIdentifier}";
private string TempDir => Path.Combine(AssemblySetUp.TempDir, Name, NuGetPackageSource.ToString());
private string TempDir => Path.Combine(AssemblySetUp.TempDir, Name, NuGetPackageSource.Name, RuntimeIdentifier.Name );
public abstract string Name { get; }
public abstract string OutputPath { get; }
public abstract TemplateType Type { get; }
public virtual string RelativeUrl => string.Empty;
@ -89,7 +93,7 @@ namespace AspNetCoreSdkTests.Templates
{
Directory.CreateDirectory(TempDir);
DotNetUtil.New(Name, TempDir);
DotNetUtil.Restore(TempDir, NuGetPackageSource);
DotNetUtil.Restore(TempDir, NuGetPackageSource, RuntimeIdentifier);
return IOUtil.GetFiles(Path.Combine(TempDir, "obj"));
}
@ -98,7 +102,7 @@ namespace AspNetCoreSdkTests.Templates
// Build depends on Restore
_ = ObjFilesAfterRestore;
DotNetUtil.Build(TempDir);
DotNetUtil.Build(TempDir, RuntimeIdentifier);
return (IOUtil.GetFiles(Path.Combine(TempDir, "obj")), IOUtil.GetFiles(Path.Combine(TempDir, "bin")));
}
@ -107,7 +111,7 @@ namespace AspNetCoreSdkTests.Templates
// Publish depends on Build
_ = BinFilesAfterBuild;
DotNetUtil.Publish(TempDir);
DotNetUtil.Publish(TempDir, RuntimeIdentifier);
return IOUtil.GetFiles(Path.Combine(TempDir, DotNetUtil.PublishOutput));
}
@ -116,7 +120,7 @@ namespace AspNetCoreSdkTests.Templates
// Run depends on Build
_ = BinFilesAfterBuild;
return GetHttpResponses(DotNetUtil.Run(TempDir));
return GetHttpResponses(DotNetUtil.Run(TempDir, RuntimeIdentifier));
}
private (HttpResponseMessage Http, HttpResponseMessage Https) GetHttpResponsesAfterExec()
@ -124,7 +128,7 @@ namespace AspNetCoreSdkTests.Templates
// Exec depends on Publish
_ = FilesAfterPublish;
return GetHttpResponses(DotNetUtil.Exec(TempDir, Name));
return GetHttpResponses(DotNetUtil.Exec(TempDir, Name, RuntimeIdentifier));
}
private (HttpResponseMessage Http, HttpResponseMessage Https) GetHttpResponses(

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -19,9 +20,190 @@ namespace AspNetCoreSdkTests.Templates
$"{Name}.RazorTargetAssemblyInfo.cache",
}.Select(p => Path.Combine(OutputPath, p)));
public override IEnumerable<string> ExpectedFilesAfterPublish => Enumerable.Concat(base.ExpectedFilesAfterPublish, new[]
{
"web.config",
});
private IDictionary<RuntimeIdentifier, Func<IEnumerable<string>>> _additionalFilesAfterPublish =>
new Dictionary<RuntimeIdentifier, Func<IEnumerable<string>>>()
{
{ RuntimeIdentifier.None, () => new[]
{
// Publish includes all *.config and *.json files (https://github.com/aspnet/websdk/issues/334)
"NuGet.config",
"web.config",
}
},
{ RuntimeIdentifier.Win_x64, () => Enumerable.Concat(_additionalFilesAfterPublish[RuntimeIdentifier.None](), new[]
{
"Microsoft.AspNetCore.Antiforgery.dll",
"Microsoft.AspNetCore.Authentication.Abstractions.dll",
"Microsoft.AspNetCore.Authentication.Cookies.dll",
"Microsoft.AspNetCore.Authentication.Core.dll",
"Microsoft.AspNetCore.Authentication.dll",
"Microsoft.AspNetCore.Authentication.Facebook.dll",
"Microsoft.AspNetCore.Authentication.Google.dll",
"Microsoft.AspNetCore.Authentication.JwtBearer.dll",
"Microsoft.AspNetCore.Authentication.MicrosoftAccount.dll",
"Microsoft.AspNetCore.Authentication.OAuth.dll",
"Microsoft.AspNetCore.Authentication.OpenIdConnect.dll",
"Microsoft.AspNetCore.Authentication.Twitter.dll",
"Microsoft.AspNetCore.Authentication.WsFederation.dll",
"Microsoft.AspNetCore.Authorization.dll",
"Microsoft.AspNetCore.Authorization.Policy.dll",
"Microsoft.AspNetCore.Connections.Abstractions.dll",
"Microsoft.AspNetCore.CookiePolicy.dll",
"Microsoft.AspNetCore.Cors.dll",
"Microsoft.AspNetCore.Cryptography.Internal.dll",
"Microsoft.AspNetCore.Cryptography.KeyDerivation.dll",
"Microsoft.AspNetCore.DataProtection.Abstractions.dll",
"Microsoft.AspNetCore.DataProtection.dll",
"Microsoft.AspNetCore.DataProtection.Extensions.dll",
"Microsoft.AspNetCore.Diagnostics.Abstractions.dll",
"Microsoft.AspNetCore.Diagnostics.dll",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.dll",
"Microsoft.AspNetCore.dll",
"Microsoft.AspNetCore.HostFiltering.dll",
"Microsoft.AspNetCore.Hosting.Abstractions.dll",
"Microsoft.AspNetCore.Hosting.dll",
"Microsoft.AspNetCore.Hosting.Server.Abstractions.dll",
"Microsoft.AspNetCore.Html.Abstractions.dll",
"Microsoft.AspNetCore.Http.Abstractions.dll",
"Microsoft.AspNetCore.Http.Connections.Common.dll",
"Microsoft.AspNetCore.Http.Connections.dll",
"Microsoft.AspNetCore.Http.dll",
"Microsoft.AspNetCore.Http.Extensions.dll",
"Microsoft.AspNetCore.Http.Features.dll",
"Microsoft.AspNetCore.HttpOverrides.dll",
"Microsoft.AspNetCore.HttpsPolicy.dll",
"Microsoft.AspNetCore.Identity.dll",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore.dll",
"Microsoft.AspNetCore.Identity.UI.dll",
"Microsoft.AspNetCore.Identity.UI.Views.dll",
"Microsoft.AspNetCore.JsonPatch.dll",
"Microsoft.AspNetCore.Localization.dll",
"Microsoft.AspNetCore.Localization.Routing.dll",
"Microsoft.AspNetCore.MiddlewareAnalysis.dll",
"Microsoft.AspNetCore.Mvc.Abstractions.dll",
"Microsoft.AspNetCore.Mvc.ApiExplorer.dll",
"Microsoft.AspNetCore.Mvc.Core.dll",
"Microsoft.AspNetCore.Mvc.Cors.dll",
"Microsoft.AspNetCore.Mvc.DataAnnotations.dll",
"Microsoft.AspNetCore.Mvc.dll",
"Microsoft.AspNetCore.Mvc.Formatters.Json.dll",
"Microsoft.AspNetCore.Mvc.Formatters.Xml.dll",
"Microsoft.AspNetCore.Mvc.Localization.dll",
"Microsoft.AspNetCore.Mvc.Razor.dll",
"Microsoft.AspNetCore.Mvc.Razor.Extensions.dll",
"Microsoft.AspNetCore.Mvc.RazorPages.dll",
"Microsoft.AspNetCore.Mvc.TagHelpers.dll",
"Microsoft.AspNetCore.Mvc.ViewFeatures.dll",
"Microsoft.AspNetCore.NodeServices.dll",
"Microsoft.AspNetCore.Owin.dll",
"Microsoft.AspNetCore.Razor.dll",
"Microsoft.AspNetCore.Razor.Language.dll",
"Microsoft.AspNetCore.Razor.Runtime.dll",
"Microsoft.AspNetCore.ResponseCaching.Abstractions.dll",
"Microsoft.AspNetCore.ResponseCaching.dll",
"Microsoft.AspNetCore.ResponseCompression.dll",
"Microsoft.AspNetCore.Rewrite.dll",
"Microsoft.AspNetCore.Routing.Abstractions.dll",
"Microsoft.AspNetCore.Routing.dll",
"Microsoft.AspNetCore.Server.HttpSys.dll",
"Microsoft.AspNetCore.Server.IISIntegration.dll",
"Microsoft.AspNetCore.Server.Kestrel.Core.dll",
"Microsoft.AspNetCore.Server.Kestrel.dll",
"Microsoft.AspNetCore.Server.Kestrel.Https.dll",
"Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.dll",
"Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll",
"Microsoft.AspNetCore.Session.dll",
"Microsoft.AspNetCore.SignalR.Common.dll",
"Microsoft.AspNetCore.SignalR.Core.dll",
"Microsoft.AspNetCore.SignalR.dll",
"Microsoft.AspNetCore.SignalR.Protocols.Json.dll",
"Microsoft.AspNetCore.SpaServices.dll",
"Microsoft.AspNetCore.SpaServices.Extensions.dll",
"Microsoft.AspNetCore.StaticFiles.dll",
"Microsoft.AspNetCore.WebSockets.dll",
"Microsoft.AspNetCore.WebUtilities.dll",
"Microsoft.CodeAnalysis.CSharp.dll",
"Microsoft.CodeAnalysis.dll",
"Microsoft.CodeAnalysis.Razor.dll",
"System.Data.SqlClient.dll",
"Microsoft.DotNet.PlatformAbstractions.dll",
"Microsoft.EntityFrameworkCore.Abstractions.dll",
"Microsoft.EntityFrameworkCore.Design.dll",
"Microsoft.EntityFrameworkCore.dll",
"Microsoft.EntityFrameworkCore.InMemory.dll",
"Microsoft.EntityFrameworkCore.Relational.dll",
"Microsoft.EntityFrameworkCore.SqlServer.dll",
"Microsoft.Extensions.Caching.Abstractions.dll",
"Microsoft.Extensions.Caching.Memory.dll",
"Microsoft.Extensions.Caching.SqlServer.dll",
"Microsoft.Extensions.Configuration.Abstractions.dll",
"Microsoft.Extensions.Configuration.Binder.dll",
"Microsoft.Extensions.Configuration.CommandLine.dll",
"Microsoft.Extensions.Configuration.dll",
"Microsoft.Extensions.Configuration.EnvironmentVariables.dll",
"Microsoft.Extensions.Configuration.FileExtensions.dll",
"Microsoft.Extensions.Configuration.Ini.dll",
"Microsoft.Extensions.Configuration.Json.dll",
"Microsoft.Extensions.Configuration.KeyPerFile.dll",
"Microsoft.Extensions.Configuration.UserSecrets.dll",
"Microsoft.Extensions.Configuration.Xml.dll",
"Microsoft.Extensions.DependencyInjection.Abstractions.dll",
"Microsoft.Extensions.DependencyInjection.dll",
"Microsoft.Extensions.DependencyModel.dll",
"Microsoft.Extensions.DiagnosticAdapter.dll",
"Microsoft.Extensions.FileProviders.Abstractions.dll",
"Microsoft.Extensions.FileProviders.Composite.dll",
"Microsoft.Extensions.FileProviders.Embedded.dll",
"Microsoft.Extensions.FileProviders.Physical.dll",
"Microsoft.Extensions.FileSystemGlobbing.dll",
"Microsoft.Extensions.Hosting.Abstractions.dll",
"Microsoft.Extensions.Hosting.dll",
"Microsoft.Extensions.Http.dll",
"Microsoft.Extensions.Identity.Core.dll",
"Microsoft.Extensions.Identity.Stores.dll",
"Microsoft.Extensions.Localization.Abstractions.dll",
"Microsoft.Extensions.Localization.dll",
"Microsoft.Extensions.Logging.Abstractions.dll",
"Microsoft.Extensions.Logging.Configuration.dll",
"Microsoft.Extensions.Logging.Console.dll",
"Microsoft.Extensions.Logging.Debug.dll",
"Microsoft.Extensions.Logging.dll",
"Microsoft.Extensions.Logging.EventSource.dll",
"Microsoft.Extensions.Logging.TraceSource.dll",
"Microsoft.Extensions.ObjectPool.dll",
"Microsoft.Extensions.Options.ConfigurationExtensions.dll",
"Microsoft.Extensions.Options.dll",
"Microsoft.Extensions.Primitives.dll",
"Microsoft.Extensions.WebEncoders.dll",
"Microsoft.IdentityModel.Logging.dll",
"Microsoft.IdentityModel.Protocols.dll",
"Microsoft.IdentityModel.Protocols.OpenIdConnect.dll",
"Microsoft.IdentityModel.Protocols.WsFederation.dll",
"Microsoft.IdentityModel.Tokens.dll",
"Microsoft.IdentityModel.Tokens.Saml.dll",
"Microsoft.IdentityModel.Xml.dll",
"Microsoft.Net.Http.Headers.dll",
"Newtonsoft.Json.Bson.dll",
"Newtonsoft.Json.dll",
"Remotion.Linq.dll",
"sni.dll",
"System.IdentityModel.Tokens.Jwt.dll",
"System.Interactive.Async.dll",
"System.IO.Pipelines.dll",
"System.Net.Http.Formatting.dll",
"System.Net.WebSockets.WebSocketProtocol.dll",
"System.Runtime.CompilerServices.Unsafe.dll",
"System.Security.Cryptography.Pkcs.dll",
"System.Security.Cryptography.Xml.dll",
"System.Security.Permissions.dll",
"System.Text.Encoding.CodePages.dll",
"System.Text.Encodings.Web.dll",
"System.Threading.Channels.dll",
})
}
};
public override IEnumerable<string> ExpectedFilesAfterPublish =>
Enumerable.Concat(base.ExpectedFilesAfterPublish, _additionalFilesAfterPublish[RuntimeIdentifier]());
}
}

View File

@ -22,11 +22,13 @@ namespace AspNetCoreSdkTests.Util
public static string PublishOutput => "pub";
private static IEnumerable<KeyValuePair<string, string>> GetEnvironment(string workingDirectory)
private static IEnumerable<KeyValuePair<string, string>> GetEnvironment(NuGetPackageSource nuGetPackageSource)
{
// Set NUGET_PACKAGES to an empty folder to ensure all packages are loaded from either NuGetFallbackFolder or configured sources,
// and *not* loaded from the default per-user global-packages folder.
yield return new KeyValuePair<string, string>("NUGET_PACKAGES", Path.Combine(workingDirectory, ".nuget", "packages"));
// Set NUGET_PACKAGES to an initially-empty, distinct folder for each NuGetPackageSource. This ensures packages are loaded
// from either NuGetFallbackFolder or configured sources, and *not* loaded from the default per-user global-packages folder.
//
// [5/7/2018] NUGET_PACKAGES cannot be set to a folder under the application due to https://github.com/dotnet/cli/issues/9216.
yield return new KeyValuePair<string, string>("NUGET_PACKAGES", Path.Combine(AssemblySetUp.TempDir, nuGetPackageSource.Name));
}
public static string New(string template, string workingDirectory)
@ -34,33 +36,44 @@ namespace AspNetCoreSdkTests.Util
// Clear all packages sources by default. May be overridden by NuGetPackageSource parameter.
File.WriteAllText(Path.Combine(workingDirectory, "NuGet.config"), _clearPackageSourcesNuGetConfig);
return RunDotNet($"new {template} --name {template} --output . --no-restore", workingDirectory, GetEnvironment(workingDirectory));
return RunDotNet($"new {template} --name {template} --output . --no-restore", workingDirectory);
}
public static string Restore(string workingDirectory, NuGetPackageSource packageSource)
public static string Restore(string workingDirectory, NuGetPackageSource packageSource, RuntimeIdentifier runtimeIdentifier)
{
return RunDotNet($"restore --no-cache {packageSource.SourceArgument}", workingDirectory, GetEnvironment(workingDirectory));
return RunDotNet($"restore --no-cache {packageSource.SourceArgument} {runtimeIdentifier.RuntimeArgument}",
workingDirectory, GetEnvironment(packageSource));
}
public static string Build(string workingDirectory)
public static string Build(string workingDirectory, RuntimeIdentifier runtimeIdentifier)
{
return RunDotNet("build --no-restore", workingDirectory, GetEnvironment(workingDirectory));
return RunDotNet($"build --no-restore {runtimeIdentifier.RuntimeArgument}", workingDirectory);
}
public static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) Run(string workingDirectory)
public static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) Run(
string workingDirectory, RuntimeIdentifier runtimeIdentifier)
{
return StartDotNet($"run --no-build {_urls}", workingDirectory, GetEnvironment(workingDirectory));
return StartDotNet($"run --no-build {_urls} {runtimeIdentifier.RuntimeArgument}", workingDirectory);
}
internal static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) Exec(string workingDirectory, string name)
public static string Publish(string workingDirectory, RuntimeIdentifier runtimeIdentifier)
{
var path = Path.Combine(PublishOutput, $"{name}.dll");
return StartDotNet($"exec {path} {_urls}", workingDirectory, GetEnvironment(workingDirectory));
return RunDotNet($"publish --no-build -o {PublishOutput} {runtimeIdentifier.RuntimeArgument}", workingDirectory);
}
public static string Publish(string workingDirectory)
internal static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) Exec(
string workingDirectory, string name, RuntimeIdentifier runtimeIdentifier)
{
return RunDotNet($"publish --no-build -o {PublishOutput}", workingDirectory, GetEnvironment(workingDirectory));
if (runtimeIdentifier == RuntimeIdentifier.None)
{
var path = Path.Combine(PublishOutput, $"{name}.dll");
return StartDotNet($"exec {path} {_urls}", workingDirectory);
}
else
{
var path = Path.Combine(workingDirectory, PublishOutput, $"{name}.exe");
return StartProcess(path, _urls, workingDirectory);
}
}
private static string RunDotNet(string arguments, string workingDirectory,