Skip to content

Commit 51e6492

Browse files
authored
Update for SDK 2.2.100-preview1 (#15)
1 parent f385308 commit 51e6492

14 files changed

+421
-166
lines changed

AspNetCoreSdkTests/AspNetCoreSdkTests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
14+
<PackageReference Include="NuGet.Versioning" Version="4.7.0" />
1415
<PackageReference Include="NUnit" Version="3.10.1" />
1516
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
1617
</ItemGroup>

AspNetCoreSdkTests/RuntimeIdentifier.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ public class RuntimeIdentifier
1515
public static RuntimeIdentifier Linux_x64 = new RuntimeIdentifier() {
1616
Name = "linux-x64",
1717
OSPlatforms = new[] { OSPlatform.Linux, },
18+
ExecutableFileExtension = string.Empty,
1819
};
1920

2021
public static RuntimeIdentifier OSX_x64 = new RuntimeIdentifier()
2122
{
2223
Name = "osx-x64",
2324
OSPlatforms = new[] { OSPlatform.OSX, },
25+
ExecutableFileExtension = string.Empty,
2426
};
2527

2628
public static RuntimeIdentifier Win_x64 = new RuntimeIdentifier()
2729
{
2830
Name = "win-x64",
2931
OSPlatforms = new[] { OSPlatform.Windows, },
32+
ExecutableFileExtension = ".exe",
3033
};
3134

3235
public static IEnumerable<RuntimeIdentifier> All = new[]
@@ -43,6 +46,7 @@ private RuntimeIdentifier() { }
4346
public string RuntimeArgument => (this == None) ? string.Empty : $"--runtime {Name}";
4447
public string Path => (this == None) ? string.Empty : Name;
4548
public IEnumerable<OSPlatform> OSPlatforms { get; private set; }
49+
public string ExecutableFileExtension { get; private set; }
4650

4751
public override string ToString() => Name;
4852
}

AspNetCoreSdkTests/TemplateTests.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using AspNetCoreSdkTests.Templates;
22
using AspNetCoreSdkTests.Util;
3+
using NuGet.Versioning;
34
using NUnit.Framework;
45
using System;
56
using System.Collections.Generic;
@@ -19,6 +20,13 @@ public void Restore(Template template)
1920
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterRestore, template.ObjFilesAfterRestore);
2021
}
2122

23+
[Test]
24+
[TestCaseSource(nameof(RestoreData))]
25+
public void RestoreIncremental(Template template)
26+
{
27+
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterRestore, template.ObjFilesAfterRestoreIncremental);
28+
}
29+
2230
[Test]
2331
[TestCaseSource(nameof(BuildData))]
2432
public void Build(Template template)
@@ -27,11 +35,30 @@ public void Build(Template template)
2735
CollectionAssert.AreEquivalent(template.ExpectedBinFilesAfterBuild, template.BinFilesAfterBuild);
2836
}
2937

38+
[Test]
39+
[TestCaseSource(nameof(BuildData))]
40+
public void BuildIncremental(Template template)
41+
{
42+
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterBuild, template.ObjFilesAfterBuildIncremental);
43+
CollectionAssert.AreEquivalent(template.ExpectedBinFilesAfterBuild, template.BinFilesAfterBuildIncremental);
44+
}
45+
3046
[Test]
3147
[TestCaseSource(nameof(PublishData))]
3248
public void Publish(Template template)
3349
{
34-
CollectionAssert.AreEquivalent(template.ExpectedFilesAfterPublish, template.FilesAfterPublish);
50+
var expected = template.ExpectedFilesAfterPublish;
51+
var actual = template.FilesAfterPublish;
52+
CollectionAssert.AreEquivalent(expected, actual);
53+
}
54+
55+
[Test]
56+
[TestCaseSource(nameof(PublishData))]
57+
public void PublishIncremental(Template template)
58+
{
59+
var expected = template.ExpectedFilesAfterPublish;
60+
var actual = template.FilesAfterPublishIncremental;
61+
CollectionAssert.AreEquivalent(expected, actual);
3562
}
3663

3764
[Test]
@@ -85,11 +112,11 @@ private static string GetMessage(HttpStatusCode statusCode, string serverOutput,
85112
private static IEnumerable<Template> GetTemplates(RuntimeIdentifier runtimeIdentifier)
86113
{
87114
// Offline restore is broken in SDK 2.1.301 (https://github.com/aspnet/Universe/issues/1220)
88-
var offlinePackageSource = (DotNetUtil.SdkVersion == new Version(2, 1, 301)) ?
115+
var offlinePackageSource = (DotNetUtil.SdkVersion == new SemanticVersion(2, 1, 301)) ?
89116
NuGetPackageSource.NuGetOrg : NuGetPackageSource.None;
90117

91118
// Pre-release SDKs require a private nuget feed
92-
var onlinePackageSource = (DotNetUtil.SdkVersion == new Version(2, 1, 401)) ?
119+
var onlinePackageSource = (DotNetUtil.SdkVersion.IsPrerelease) ?
93120
NuGetPackageSource.EnvironmentVariableAndNuGetOrg : NuGetPackageSource.NuGetOrg;
94121

95122
if (runtimeIdentifier == RuntimeIdentifier.None)
Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Collections.Generic;
1+
using AspNetCoreSdkTests.Util;
2+
using System;
3+
using System.Collections.Generic;
24
using System.IO;
35
using System.Linq;
46
using System.Text.RegularExpressions;
@@ -11,26 +13,52 @@ public AngularTemplate() { }
1113

1214
public override string Name => "angular";
1315

14-
// Remove generated hashes since they may vary by platform
15-
public override IEnumerable<string> FilesAfterPublish =>
16-
base.FilesAfterPublish.Select(f => Regex.Replace(f, @"\.[0-9a-f]{20}\.", ".[HASH]."));
16+
protected override IEnumerable<string> NormalizeFilesAfterPublish(IEnumerable<string> filesAfterPublish)
17+
{
18+
// Remove generated hashes since they may vary by platform
19+
return base.NormalizeFilesAfterPublish(filesAfterPublish)
20+
.Select(f => Regex.Replace(f, @"\.[0-9a-f]{20}\.", ".[HASH]."));
21+
}
1722

18-
public override IEnumerable<string> ExpectedFilesAfterPublish =>
19-
base.ExpectedFilesAfterPublish
20-
.Concat(new[]
23+
private IDictionary<string, Func<IEnumerable<string>>> _additionalFilesAfterPublish =>
24+
new Dictionary<string, Func<IEnumerable<string>>>()
2125
{
22-
Path.Combine("wwwroot", "favicon.ico"),
23-
Path.Combine("ClientApp", "dist", "3rdpartylicenses.txt"),
24-
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].woff2"),
25-
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].svg"),
26-
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].ttf"),
27-
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].eot"),
28-
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].woff"),
29-
Path.Combine("ClientApp", "dist", "index.html"),
30-
Path.Combine("ClientApp", "dist", "inline.[HASH].bundle.js"),
31-
Path.Combine("ClientApp", "dist", "main.[HASH].bundle.js"),
32-
Path.Combine("ClientApp", "dist", "polyfills.[HASH].bundle.js"),
33-
Path.Combine("ClientApp", "dist", "styles.[HASH].bundle.css"),
34-
});
26+
{ "common", () => new[]
27+
{
28+
Path.Combine("wwwroot", "favicon.ico"),
29+
Path.Combine("ClientApp", "dist", "3rdpartylicenses.txt"),
30+
Path.Combine("ClientApp", "dist", "index.html"),
31+
}
32+
},
33+
{ "netcoreapp2.1", () =>
34+
_additionalFilesAfterPublish["common"]()
35+
.Concat(new[]
36+
{
37+
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].woff2"),
38+
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].svg"),
39+
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].ttf"),
40+
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].eot"),
41+
Path.Combine("ClientApp", "dist", "glyphicons-halflings-regular.[HASH].woff"),
42+
Path.Combine("ClientApp", "dist", $"inline.[HASH].bundle.js"),
43+
Path.Combine("ClientApp", "dist", $"main.[HASH].bundle.js"),
44+
Path.Combine("ClientApp", "dist", $"polyfills.[HASH].bundle.js"),
45+
Path.Combine("ClientApp", "dist", $"styles.[HASH].bundle.css"),
46+
})
47+
},
48+
{ "netcoreapp2.2", () =>
49+
_additionalFilesAfterPublish["common"]()
50+
.Concat(new[]
51+
{
52+
Path.Combine("ClientApp", "dist", $"runtime.[HASH].js"),
53+
Path.Combine("ClientApp", "dist", $"main.[HASH].js"),
54+
Path.Combine("ClientApp", "dist", $"polyfills.[HASH].js"),
55+
Path.Combine("ClientApp", "dist", $"styles.[HASH].css"),
56+
})
57+
},
58+
};
59+
60+
public override IEnumerable<string> ExpectedFilesAfterPublish =>
61+
base.ExpectedFilesAfterPublish
62+
.Concat(_additionalFilesAfterPublish[DotNetUtil.TargetFrameworkMoniker]());
3563
}
3664
}

AspNetCoreSdkTests/Templates/ConsoleApplicationTemplate.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using AspNetCoreSdkTests.Util;
2+
using System;
23
using System.Collections.Generic;
34
using System.IO;
45
using System.Linq;
@@ -12,7 +13,7 @@ public ConsoleApplicationTemplate() { }
1213

1314
public override string Name => "console";
1415

15-
public override string OutputPath => Path.Combine("Debug", "netcoreapp2.1", RuntimeIdentifier.Path);
16+
public override string OutputPath => Path.Combine("Debug", DotNetUtil.TargetFrameworkMoniker, RuntimeIdentifier.Path);
1617

1718
public override TemplateType Type => TemplateType.ConsoleApplication;
1819

@@ -22,12 +23,12 @@ public ConsoleApplicationTemplate() { }
2223
{ RuntimeIdentifier.None, () => Enumerable.Empty<string>() },
2324
{ RuntimeIdentifier.Win_x64, () => new[]
2425
{
25-
Path.Combine("netcoreapp2.1", RuntimeIdentifier.Path, "host", $"{Name}.exe"),
26+
Path.Combine(DotNetUtil.TargetFrameworkMoniker, RuntimeIdentifier.Path, "host", $"{Name}.exe"),
2627
}
2728
},
2829
{ RuntimeIdentifier.Linux_x64, () => new[]
2930
{
30-
Path.Combine("netcoreapp2.1", RuntimeIdentifier.Path, "host", $"{Name}"),
31+
Path.Combine(DotNetUtil.TargetFrameworkMoniker, RuntimeIdentifier.Path, "host", $"{Name}"),
3132
}
3233
},
3334
{ RuntimeIdentifier.OSX_x64, () => _additionalObjFilesAfterBuild[RuntimeIdentifier.Linux_x64]() },
@@ -74,11 +75,13 @@ public ConsoleApplicationTemplate() { }
7475
base.ExpectedBinFilesAfterBuild
7576
.Concat(_additionalBinFilesAfterBuild[RuntimeIdentifier]());
7677

77-
// A few files included in self-contained deployments contain version numbers in the filename, which must
78-
// be replaced so tests can pass on all versions.
79-
public override IEnumerable<string> FilesAfterPublish =>
80-
base.FilesAfterPublish
81-
.Select(f => Regex.Replace(f, @"_amd64_amd64_[0-9\.]+\.dll$", "_amd64_amd64_[VERSION].dll"));
78+
protected override IEnumerable<string> NormalizeFilesAfterPublish(IEnumerable<string> filesAfterPublish)
79+
{
80+
// A few files included in self-contained deployments contain version numbers in the filename, which must
81+
// be replaced so tests can pass on all versions.
82+
return base.NormalizeFilesAfterPublish(filesAfterPublish)
83+
.Select(f => Regex.Replace(f, @"_amd64_amd64_[0-9\.]+\.dll$", "_amd64_amd64_[VERSION].dll"));
84+
}
8285

8386
private Func<IEnumerable<string>> _additionalFilesAfterPublishCommon = () => new[]
8487
{
Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Collections.Generic;
1+
using AspNetCoreSdkTests.Util;
2+
using System;
3+
using System.Collections.Generic;
24
using System.IO;
35
using System.Linq;
46

@@ -12,19 +14,33 @@ public MvcTemplate() { }
1214

1315
protected override string RazorPath => "Views";
1416

17+
private IDictionary<string, Func<IEnumerable<string>>> _additionalObjFilesAfterBuild =>
18+
new Dictionary<string, Func<IEnumerable<string>>>()
19+
{
20+
{ "common", () => new[]
21+
{
22+
Path.Combine("Razor", RazorPath, "_ViewStart.g.cshtml.cs"),
23+
Path.Combine("Razor", RazorPath, "Home", "Index.g.cshtml.cs"),
24+
Path.Combine("Razor", RazorPath, "Home", "Privacy.g.cshtml.cs"),
25+
Path.Combine("Razor", RazorPath, "Shared", "_CookieConsentPartial.g.cshtml.cs"),
26+
Path.Combine("Razor", RazorPath, "Shared", "_Layout.g.cshtml.cs"),
27+
Path.Combine("Razor", RazorPath, "Shared", "_ValidationScriptsPartial.g.cshtml.cs"),
28+
Path.Combine("Razor", RazorPath, "Shared", "Error.g.cshtml.cs"),
29+
}
30+
},
31+
{ "netcoreapp2.1", () =>
32+
_additionalObjFilesAfterBuild["common"]()
33+
.Concat(new[]
34+
{
35+
Path.Combine("Razor", RazorPath, "Home", "About.g.cshtml.cs"),
36+
Path.Combine("Razor", RazorPath, "Home", "Contact.g.cshtml.cs"),
37+
})
38+
},
39+
{ "netcoreapp2.2", () => _additionalObjFilesAfterBuild["common"]() },
40+
};
41+
1542
public override IEnumerable<string> ExpectedObjFilesAfterBuild =>
1643
base.ExpectedObjFilesAfterBuild
17-
.Concat(new[]
18-
{
19-
Path.Combine("Razor", RazorPath, "_ViewStart.g.cshtml.cs"),
20-
Path.Combine("Razor", RazorPath, "Home", "About.g.cshtml.cs"),
21-
Path.Combine("Razor", RazorPath, "Home", "Contact.g.cshtml.cs"),
22-
Path.Combine("Razor", RazorPath, "Home", "Index.g.cshtml.cs"),
23-
Path.Combine("Razor", RazorPath, "Home", "Privacy.g.cshtml.cs"),
24-
Path.Combine("Razor", RazorPath, "Shared", "_CookieConsentPartial.g.cshtml.cs"),
25-
Path.Combine("Razor", RazorPath, "Shared", "_Layout.g.cshtml.cs"),
26-
Path.Combine("Razor", RazorPath, "Shared", "_ValidationScriptsPartial.g.cshtml.cs"),
27-
Path.Combine("Razor", RazorPath, "Shared", "Error.g.cshtml.cs"),
28-
}.Select(p => Path.Combine(OutputPath, p)));
44+
.Concat(_additionalObjFilesAfterBuild[DotNetUtil.TargetFrameworkMoniker]().Select(p => Path.Combine(OutputPath, p)));
2945
}
3046
}

AspNetCoreSdkTests/Templates/RazorApplicationBaseTemplate.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using AspNetCoreSdkTests.Util;
2+
using System;
23
using System.Collections.Generic;
34
using System.IO;
45
using System.Linq;
@@ -21,14 +22,14 @@ public abstract class RazorApplicationBaseTemplate : WebTemplate
2122
_additionalObjFilesAfterBuild[RuntimeIdentifier.None]()
2223
.Concat(new[]
2324
{
24-
Path.Combine("netcoreapp2.1", RuntimeIdentifier.Path, "host", $"{Name}.exe"),
25+
Path.Combine(DotNetUtil.TargetFrameworkMoniker, RuntimeIdentifier.Path, "host", $"{Name}.exe"),
2526
})
2627
},
2728
{ RuntimeIdentifier.Linux_x64, () =>
2829
_additionalObjFilesAfterBuild[RuntimeIdentifier.None]()
2930
.Concat(new[]
3031
{
31-
Path.Combine("netcoreapp2.1", RuntimeIdentifier.Path, "host", $"{Name}"),
32+
Path.Combine(DotNetUtil.TargetFrameworkMoniker, RuntimeIdentifier.Path, "host", $"{Name}"),
3233
})
3334
},
3435
{ RuntimeIdentifier.OSX_x64, () => _additionalObjFilesAfterBuild[RuntimeIdentifier.Linux_x64]() },

0 commit comments

Comments
 (0)