diff --git a/Templating.sln b/Templating.sln
index a00f768587..bfcfcdeb7d 100644
--- a/Templating.sln
+++ b/Templating.sln
@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Web.Projec
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TemplatePackages", "TemplatePackages", "{0AD6E692-E423-408C-B523-DAFB19412E4B}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyUpdater", "tools\DependencyUpdater\DependencyUpdater.csproj", "{15806338-550D-4418-99AE-42FDAE03808A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -35,6 +37,10 @@ Global
{62D00388-8824-4661-8CC8-8D8436FF97E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62D00388-8824-4661-8CC8-8D8436FF97E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62D00388-8824-4661-8CC8-8D8436FF97E6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {15806338-550D-4418-99AE-42FDAE03808A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {15806338-550D-4418-99AE-42FDAE03808A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {15806338-550D-4418-99AE-42FDAE03808A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {15806338-550D-4418-99AE-42FDAE03808A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index cf686c1544..93d17fb6ce 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -10,8 +10,9 @@
2008;8021
$(VersionPrefix)
$(VersionPrefix)-$(VersionSuffix)
- $(MSBuildThisFileDirectory)..\artifacts\
+ $(MSBuildThisFileDirectory)..\artifacts\tmp\
version=$(PackageVersion)
+ @(PackageReference->WithMetadataValue('Identity', 'Microsoft.AspNetCore.All')->Metadata('Version'))
+
diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets
new file mode 100644
index 0000000000..bedfa31a75
--- /dev/null
+++ b/src/Directory.Build.targets
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/EmptyWeb-CSharp/Company.WebApplication1.csproj b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/EmptyWeb-CSharp/Company.WebApplication1.csproj
index 7ebcba7fd0..307f6e133b 100644
--- a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/EmptyWeb-CSharp/Company.WebApplication1.csproj
+++ b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/EmptyWeb-CSharp/Company.WebApplication1.csproj
@@ -10,10 +10,10 @@
-
+
-
+
diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/EmptyWeb-FSharp/Company.WebApplication1.fsproj b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/EmptyWeb-FSharp/Company.WebApplication1.fsproj
index 4ee5c425be..d1104b7c85 100644
--- a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/EmptyWeb-FSharp/Company.WebApplication1.fsproj
+++ b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/EmptyWeb-FSharp/Company.WebApplication1.fsproj
@@ -11,7 +11,7 @@
-
+
diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/RazorPagesWeb-CSharp/Company.WebApplication1.csproj b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/RazorPagesWeb-CSharp/Company.WebApplication1.csproj
index 5739651b2c..292929d3e4 100644
--- a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/RazorPagesWeb-CSharp/Company.WebApplication1.csproj
+++ b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/RazorPagesWeb-CSharp/Company.WebApplication1.csproj
@@ -10,19 +10,19 @@
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/StarterWeb-CSharp/Company.WebApplication1.csproj b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/StarterWeb-CSharp/Company.WebApplication1.csproj
index 71b7438ba8..a3ff9ac842 100644
--- a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/StarterWeb-CSharp/Company.WebApplication1.csproj
+++ b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/StarterWeb-CSharp/Company.WebApplication1.csproj
@@ -15,19 +15,19 @@
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/StarterWeb-FSharp/Company.WebApplication1.fsproj b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/StarterWeb-FSharp/Company.WebApplication1.fsproj
index f031023c67..fd51734d63 100644
--- a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/StarterWeb-FSharp/Company.WebApplication1.fsproj
+++ b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/StarterWeb-FSharp/Company.WebApplication1.fsproj
@@ -14,13 +14,13 @@
-
+
-
-
-
-
+
+
+
+
diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-CSharp/Company.WebApplication1.csproj b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-CSharp/Company.WebApplication1.csproj
index 4a6b89e76f..a5c2431a86 100644
--- a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-CSharp/Company.WebApplication1.csproj
+++ b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-CSharp/Company.WebApplication1.csproj
@@ -13,12 +13,12 @@
-
+
-
-
-
+
+
+
diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-FSharp/Company.WebApplication1.fsproj b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-FSharp/Company.WebApplication1.fsproj
index 02154fd837..43e541444a 100644
--- a/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-FSharp/Company.WebApplication1.fsproj
+++ b/src/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-FSharp/Company.WebApplication1.fsproj
@@ -12,11 +12,11 @@
-
+
-
-
+
+
diff --git a/tools/DependencyUpdater/DependencyUpdater.csproj b/tools/DependencyUpdater/DependencyUpdater.csproj
index ffc9670f96..745210816a 100644
--- a/tools/DependencyUpdater/DependencyUpdater.csproj
+++ b/tools/DependencyUpdater/DependencyUpdater.csproj
@@ -1,6 +1,11 @@
- netcoreapp1.1
- Exe
+ netstandard2.0
+ Library
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/DependencyUpdater/EncodingUtil.cs b/tools/DependencyUpdater/EncodingUtil.cs
deleted file mode 100644
index c260450763..0000000000
--- a/tools/DependencyUpdater/EncodingUtil.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System.Text;
-
-namespace DependencyUpdater
-{
- public class EncodingUtil
- {
- /// http://www.unicode.org/faq/utf_bom.html
- public static Encoding Detect(byte[] buffer, int currentBufferLength, out byte[] bom)
- {
- if (currentBufferLength == 0)
- {
- //File is zero length - pick something
- bom = new byte[0];
- return Encoding.UTF8;
- }
-
- if (currentBufferLength >= 4)
- {
- if (buffer[0] == 0x00 && buffer[1] == 0x00 && buffer[2] == 0xFE && buffer[3] == 0xFF)
- {
- //Big endian UTF-32
- bom = new byte[] { 0x00, 0x00, 0xFE, 0xFF };
- return Encoding.GetEncoding(12001);
- }
-
- if (buffer[0] == 0xFF && buffer[1] == 0xFE && buffer[2] == 0x00 && buffer[3] == 0x00)
- {
- //Little endian UTF-32
- bom = new byte[] { 0xFF, 0xFE, 0x00, 0x00 };
- return Encoding.UTF32;
- }
- }
-
- if (currentBufferLength >= 3)
- {
- if (buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF)
- {
- //UTF-8
- bom = new byte[] { 0xEF, 0xBB, 0xBF };
- return Encoding.UTF8;
- }
- }
-
- if (currentBufferLength >= 2)
- {
- if (buffer[0] == 0xFE && buffer[1] == 0xFF)
- {
- //Big endian UTF-16
- bom = new byte[] { 0xFE, 0xFF };
- return Encoding.BigEndianUnicode;
- }
-
- if (buffer[0] == 0xFF && buffer[1] == 0xFE)
- {
- //Little endian UTF-16
- bom = new byte[] { 0xFF, 0xFE };
- return Encoding.Unicode;
- }
- }
-
- //Fallback to UTF-8
- bom = new byte[0];
- return Encoding.UTF8;
- }
- }
-}
diff --git a/tools/DependencyUpdater/Program.cs b/tools/DependencyUpdater/Program.cs
deleted file mode 100644
index 2c47629f73..0000000000
--- a/tools/DependencyUpdater/Program.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace DependencyUpdater
-{
- class Program
- {
- static int Main(string[] args)
- {
- if(args.Length < 2)
- {
- Console.WriteLine(@"Usage:
-dotnet DependencyUpdater.dll [path to templates:string] [infer no-timestamp packages from semaphore files] [[paths to package sources]]");
- return -1;
- }
-
- bool NoTimestamp = bool.Parse(args[1]);
- string root = args[0];
- List sources = new List();
-
- foreach(string arg in args.Skip(2))
- {
- if (Directory.Exists(arg))
- {
- sources.Add(arg);
- }
- else if (File.Exists(arg))
- {
- string sem = File.ReadAllText(arg);
-
- foreach (string line in sem.Split('\n'))
- {
- string trimmed = line.Trim();
- string share = trimmed.Substring(trimmed.LastIndexOf(':') + 1).Trim();
- string source = Path.Combine(share, @"Signed\Packages") + (NoTimestamp ? "-NoTimeStamp" : "");
-
- if (Directory.Exists(source))
- {
- sources.Add(source);
- }
- }
- }
- else
- {
- Console.Error.WriteLine($"Unknown source: \"{arg}\"");
- }
- }
-
- Regex versionPattern = new Regex(@"\d+\.\d+\.\d+([-\+].*)?");
- List> replacements = new List>();
-
- foreach (string source in sources)
- {
- foreach (string file in Directory.EnumerateFiles(source, "*.nupkg", SearchOption.AllDirectories))
- {
- string packageIdAndVersion = Path.GetFileNameWithoutExtension(file);
- Match m = versionPattern.Match(packageIdAndVersion);
- string packageId = packageIdAndVersion.Substring(0, m.Index).TrimEnd('.');
- string version = packageIdAndVersion.Substring(m.Index);
- int versionFirstDot = version.IndexOf('.');
- int versionSecondDot = version.IndexOf('.', versionFirstDot + 1);
- string majorMinor = version.Substring(0, versionSecondDot);
- string majorMinorEscaped = Regex.Escape(majorMinor);
-
- Regex rx = new Regex($"(?<=\"{packageId}\"\\s+Version\\s*=\\s*\"){majorMinorEscaped}[^\"]*(?=\")");
- replacements.Add(Tuple.Create(packageId, rx, version));
- }
- }
-
- foreach(string project in Directory.EnumerateFiles(root, "*.*proj", SearchOption.AllDirectories))
- {
- if(Path.GetExtension(project).ToUpperInvariant() == ".PROJ" || Path.GetFileName(project).ToUpperInvariant() == "BUILD.CSPROJ")
- {
- continue;
- }
-
- string source = File.ReadAllText(project);
- string result = source;
- foreach(Tuple replacement in replacements)
- {
- string orig = result;
- result = replacement.Item2.Replace(result, replacement.Item3);
-
- if(orig != result)
- {
- Console.WriteLine($"{project.Substring(root.Length).TrimStart('\\', '/')}: {replacement.Item1} -> {replacement.Item3}");
- }
- }
-
- byte[] data = File.ReadAllBytes(project);
- Encoding encoding = EncodingUtil.Detect(data, data.Length, out byte[] bom);
-
- if(bom.Length == 0 && Encoding.UTF8.EncodingName == encoding.EncodingName)
- {
- encoding = new UTF8Encoding(false);
- }
-
- File.WriteAllText(project, result, encoding);
- }
-
- return 0;
- }
- }
-}
diff --git a/tools/DependencyUpdater/UpdateAspNetReference.cs b/tools/DependencyUpdater/UpdateAspNetReference.cs
new file mode 100644
index 0000000000..305a271bc0
--- /dev/null
+++ b/tools/DependencyUpdater/UpdateAspNetReference.cs
@@ -0,0 +1,78 @@
+using Microsoft.Build.Utilities;
+using System;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+
+namespace DependencyUpdater
+{
+ public class UpdateAspNetReference : Task
+ {
+ private static string[] ProjectFileExtensions = new[]
+ {
+ ".csproj",
+ ".fsproj"
+ };
+
+ public string NupkgFile { get; set; }
+ public string AspNetVersion { get; set; }
+ public string OutDir { get; set; }
+
+ public override bool Execute()
+ {
+ if (string.IsNullOrEmpty(AspNetVersion))
+ {
+ throw new ArgumentException($"No value specified for {nameof(AspNetVersion)}.");
+ }
+
+ // We can't modify the .nupkg in place because the build system still
+ // has a lock on the file. We can read it, but not write it. So copy
+ // to the output location and then modify the copy.
+ var outFile = Path.Combine(OutDir, Path.GetFileName(NupkgFile));
+ File.Copy(NupkgFile, outFile, true);
+
+ using (var zipFile = ZipFile.Open(outFile, ZipArchiveMode.Update))
+ {
+ foreach (var projectFile in zipFile.Entries.Where(IsProjectFile))
+ {
+ PerformVariableSubstitution(projectFile);
+ }
+ }
+
+ return true;
+ }
+
+ private static bool IsProjectFile(ZipArchiveEntry entry)
+ {
+ return ProjectFileExtensions.Any(
+ extension => Path.GetExtension(entry.Name).Equals(extension, StringComparison.OrdinalIgnoreCase));
+ }
+
+ private void PerformVariableSubstitution(ZipArchiveEntry entry)
+ {
+ using (var fileStream = entry.Open())
+ {
+ string contents;
+ using (var reader = new StreamReader(fileStream))
+ using (var writer = new StreamWriter(fileStream))
+ {
+ contents = reader.ReadToEnd();
+ fileStream.Seek(0, SeekOrigin.Begin);
+ fileStream.SetLength(0);
+ writer.Write(SubstituteVariables(contents));
+ }
+ }
+ }
+
+ private string SubstituteVariables(string projectFileContents)
+ {
+ // Currently we only need a way of updating ASP.NET package
+ // reference versions, so that's all this does. In the future,
+ // we could generalise this into a system for injecting
+ // versions for all packages based on the KoreBuild lineup.
+ return projectFileContents.Replace(
+ "$(TemplateAspNetCoreVersion)",
+ AspNetVersion);
+ }
+ }
+}