parent
14b08da4f3
commit
8271552cc6
|
|
@ -15,3 +15,4 @@ StyleCop.Cache
|
|||
node_modules
|
||||
*.snk
|
||||
.nuget/NuGet.exe
|
||||
project.lock.json
|
||||
|
|
@ -223,12 +223,12 @@ var buildTarget = "compile"
|
|||
-// Pin versions of packages in project.json and updated project.lock.json
|
||||
-// More information https://github.com/aspnet/Universe/wiki/%23pin-version-:-Pinning-package-version-for-a-particular-release-in-project.json
|
||||
@{
|
||||
// NOTE: Before running update the below monikers as needed
|
||||
var branch = Environment.GetEnvironmentVariable("BUILD_BRANCH");
|
||||
var stableBranches = new[] {"master"};
|
||||
var coherenceFeed = Environment.GetEnvironmentVariable("COHERENCE_FEED");
|
||||
if (string.IsNullOrEmpty(coherenceFeed))
|
||||
{
|
||||
throw new Exception("COHERENCE_FEED not specified. Usually this is Packages-NoTimestamp directory of Coherence-Signed.");
|
||||
}
|
||||
|
||||
var oldPreRelease = Environment.GetEnvironmentVariable("OLD_RELEASE");
|
||||
var newPreRelease = Environment.GetEnvironmentVariable("NEW_RELEASE");
|
||||
var excludeReposForJson = new[]
|
||||
{
|
||||
"Coherence",
|
||||
|
|
@ -237,19 +237,12 @@ var buildTarget = "compile"
|
|||
"Entropy"
|
||||
};
|
||||
|
||||
var oldCoreCLRBuild = Environment.GetEnvironmentVariable("CORECLR_RELEASE_BUILD_OLD");
|
||||
var newCoreCLRBuild = Environment.GetEnvironmentVariable("CORECLR_RELEASE_BUILD_NEW");
|
||||
var oldCoreCLRPrerelease = Environment.GetEnvironmentVariable("OLD_CORECLR_RELEASE");
|
||||
var newCoreCLRPrerelease = Environment.GetEnvironmentVariable("NEW_CORECLR_RELEASE");
|
||||
var repos = GetAllRepos().Except(excludeReposForJson);
|
||||
Parallel.ForEach(repos, CloneOrUpdate);
|
||||
|
||||
var oldRoslynPrerelease = Environment.GetEnvironmentVariable("OLD_ROSLYN_RELEASE");
|
||||
var newRoslynPrerelease = Environment.GetEnvironmentVariable("NEW_ROSLYN_RELEASE");
|
||||
|
||||
foreach (var repo in GetAllRepos().Except(excludeReposForJson))
|
||||
foreach (var repo in repos)
|
||||
{
|
||||
CloneOrUpdate(repo);
|
||||
|
||||
GitCommand(repo, string.Format("checkout {0}", branch));
|
||||
GitCommand(repo, "checkout master");
|
||||
|
||||
if (File.Exists(Path.Combine(repo, "build.cmd")))
|
||||
{
|
||||
|
|
@ -258,47 +251,9 @@ var buildTarget = "compile"
|
|||
overwrite: true);
|
||||
}
|
||||
|
||||
// Process project.json files to pin version numbers
|
||||
// Replace version in project.json
|
||||
foreach(var file in Directory.GetFiles(repo,"project.json", SearchOption.AllDirectories))
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
var contents = File.ReadAllLines(file);
|
||||
var repoPath = Path.Combine(Directory.GetCurrentDirectory(), repo);
|
||||
|
||||
foreach(var jsonEntry in contents)
|
||||
{
|
||||
if(jsonEntry.Contains("\"System.") || jsonEntry.Contains("CSharp"))
|
||||
{
|
||||
var oldSearchExp = BuildVersionExpression(branch, oldCoreCLRPrerelease, oldCoreCLRBuild);
|
||||
var newReplaceExp = BuildVersionExpression(branch, newCoreCLRPrerelease, newCoreCLRBuild);
|
||||
|
||||
builder.AppendLine(jsonEntry.Replace(oldSearchExp, newReplaceExp));
|
||||
}
|
||||
else if(jsonEntry.Contains("CodeAnalysis."))
|
||||
{
|
||||
var oldSearchExp = BuildVersionExpression(branch, oldRoslynPrerelease);
|
||||
var newReplaceExp = BuildVersionExpression(branch, newRoslynPrerelease);
|
||||
|
||||
builder.AppendLine(jsonEntry.Replace(oldSearchExp, newReplaceExp));
|
||||
}
|
||||
else if(jsonEntry.Contains("IdentityModel"))
|
||||
{
|
||||
// IdentityModel packages don't have a stable build and are updated very frequently on the NuGet feed
|
||||
builder.AppendLine(jsonEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldSearchExp = BuildVersionExpression(branch, oldPreRelease);
|
||||
var newReplaceExp = BuildVersionExpression(branch, newPreRelease);
|
||||
|
||||
var newEntry = ProcessExcludesForPackages(jsonEntry, stableBranches.Contains(branch));
|
||||
|
||||
builder.AppendLine(newEntry.Replace(oldSearchExp, newReplaceExp));
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(file, builder.ToString());
|
||||
}
|
||||
Exec("dnx", string.Format(@".\tools\PinVersion run ""{0}"" ""{1}""", repo, coherenceFeed), string.Empty);
|
||||
|
||||
// Build projects to produce project.lock.json
|
||||
Exec("build.cmd", "compile", repo);
|
||||
|
|
@ -325,7 +280,7 @@ var buildTarget = "compile"
|
|||
|
||||
GitCommand(repo, "commit -am \"Updating json files to pin versions and build.cmd to pin KoreBuild and DNX\"");
|
||||
|
||||
GitCommand(repo, string.Format("push origin {0}:{0} -f", branch));
|
||||
GitCommand(repo, "push origin master:master -f");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "PinVersion", "PinVersion\PinVersion.xproj", "{3D3B5750-0C24-4F1C-9304-B5E4D85CF5A0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3D3B5750-0C24-4F1C-9304-B5E4D85CF5A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3D3B5750-0C24-4F1C-9304-B5E4D85CF5A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3D3B5750-0C24-4F1C-9304-B5E4D85CF5A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3D3B5750-0C24-4F1C-9304-B5E4D85CF5A0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>3d3b5750-0c24-4f1c-9304-b5e4d85cf5a0</ProjectGuid>
|
||||
<RootNamespace>PinVersion</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NuGet;
|
||||
|
||||
namespace PinVersion
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public void Main(string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
Console.Error.WriteLine("Usage <repository-path> <package source>");
|
||||
}
|
||||
|
||||
var repositoryPath = args[0];
|
||||
var packageSource = args[1];
|
||||
|
||||
var packageRepository = PackageRepositoryFactory.Default.CreateRepository(packageSource);
|
||||
|
||||
foreach (var file in Directory.EnumerateFiles(repositoryPath, "project.json", SearchOption.AllDirectories))
|
||||
{
|
||||
var projectJson = JObject.Parse(File.ReadAllText(file));
|
||||
var directoryName = Path.GetFileName(Path.GetDirectoryName(file));
|
||||
var latestPackage = packageRepository.FindPackage(directoryName);
|
||||
if (latestPackage != null)
|
||||
{
|
||||
((JValue)projectJson["version"]).Value = latestPackage.Version.ToNormalizedString();
|
||||
}
|
||||
|
||||
var frameworkDependencies = projectJson["frameworks"]
|
||||
?.Cast<JProperty>()
|
||||
?.Select(f => ((JObject)f.Value)["dependencies"])
|
||||
?? Enumerable.Empty<JToken>();
|
||||
var dependencies = Enumerable.Concat(new[] { projectJson["dependencies"] }, frameworkDependencies)
|
||||
.Where(d => d != null)
|
||||
.SelectMany(d => d)
|
||||
.Cast<JProperty>();
|
||||
|
||||
foreach (var dependency in dependencies)
|
||||
{
|
||||
latestPackage = packageRepository.FindPackage(dependency.Name);
|
||||
if (latestPackage != null)
|
||||
{
|
||||
if (dependency.Value.Type == JTokenType.Object)
|
||||
{
|
||||
// "key": { "version": "1.0.0-*", "type": "build" }
|
||||
var value = (JObject)dependency.Value;
|
||||
value["version"] = latestPackage.Version.ToNormalizedString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// "key": "version"
|
||||
dependency.Value = latestPackage.Version.ToNormalizedString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var fileWriter = new JsonTextWriter(new StreamWriter(file)))
|
||||
{
|
||||
fileWriter.Formatting = Formatting.Indented;
|
||||
fileWriter.Indentation = 4;
|
||||
projectJson.WriteTo(fileWriter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "6.0.8",
|
||||
"NuGet.Core": "2.8.6"
|
||||
},
|
||||
|
||||
"commands": {
|
||||
"PinVersion": "PinVersion"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnx451": { }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue