Enable pinning build scripts(build.cmd)
This commit is contained in:
parent
7b0f6e7c2a
commit
3940873943
|
|
@ -192,6 +192,12 @@ var buildTarget = "compile"
|
||||||
throw new Exception("COHERENCE_FEED not specified. Usually this is Packages-NoTimestamp directory of Coherence-Signed.");
|
throw new Exception("COHERENCE_FEED not specified. Usually this is Packages-NoTimestamp directory of Coherence-Signed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var korebuildVersion = Environment.GetEnvironmentVariable("KOREBUILD_VERSION");
|
||||||
|
if (string.IsNullOrEmpty(korebuildVersion))
|
||||||
|
{
|
||||||
|
throw new Exception("KOREBUILD_VERSION environment variable is not specified.");
|
||||||
|
}
|
||||||
|
|
||||||
var excludeReposForJson = new[]
|
var excludeReposForJson = new[]
|
||||||
{
|
{
|
||||||
"Coherence",
|
"Coherence",
|
||||||
|
|
@ -216,7 +222,7 @@ var buildTarget = "compile"
|
||||||
|
|
||||||
var repoPath = Path.Combine(Directory.GetCurrentDirectory(), repo);
|
var repoPath = Path.Combine(Directory.GetCurrentDirectory(), repo);
|
||||||
|
|
||||||
Exec("dnx", string.Format(@".\tools\PinVersion run ""{0}"" ""{1}""", repo, coherenceFeed), string.Empty);
|
Exec("dnx", string.Format(@".\tools\PinVersion run ""{0}"" ""{1}"" ""{2}""", repo, coherenceFeed, korebuildVersion), string.Empty);
|
||||||
|
|
||||||
// Build projects to produce project.lock.json
|
// Build projects to produce project.lock.json
|
||||||
Exec("build.cmd", "compile", repo);
|
Exec("build.cmd", "compile", repo);
|
||||||
|
|
@ -661,8 +667,8 @@ functions
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IEnumerable<string> GetRepositoriesToBuild()
|
static IEnumerable<string> GetRepositoriesToBuild()
|
||||||
{
|
{
|
||||||
IEnumerable<string> reposToBuild = new HashSet<string>(StringComparer.OrdinalIgnoreCase) {
|
IEnumerable<string> reposToBuild = new HashSet<string>(StringComparer.OrdinalIgnoreCase) {
|
||||||
// The repos list is topologically sorted based on build order
|
// The repos list is topologically sorted based on build order
|
||||||
|
|
@ -703,7 +709,7 @@ functions
|
||||||
"CORS",
|
"CORS",
|
||||||
"Entropy",
|
"Entropy",
|
||||||
};
|
};
|
||||||
|
|
||||||
var repositoryInclude = Environment.GetEnvironmentVariable("KOREBUILD_REPOSITORY_INCLUDE");
|
var repositoryInclude = Environment.GetEnvironmentVariable("KOREBUILD_REPOSITORY_INCLUDE");
|
||||||
if (!string.IsNullOrEmpty(repositoryInclude))
|
if (!string.IsNullOrEmpty(repositoryInclude))
|
||||||
{
|
{
|
||||||
|
|
@ -711,14 +717,14 @@ functions
|
||||||
repositoryInclude.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries),
|
repositoryInclude.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries),
|
||||||
StringComparer.OrdinalIgnoreCase);
|
StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
var repositoryExclude = Environment.GetEnvironmentVariable("KOREBUILD_REPOSITORY_EXCLUDE");
|
var repositoryExclude = Environment.GetEnvironmentVariable("KOREBUILD_REPOSITORY_EXCLUDE");
|
||||||
if (!string.IsNullOrEmpty(repositoryExclude))
|
if (!string.IsNullOrEmpty(repositoryExclude))
|
||||||
{
|
{
|
||||||
var reposToExclude = repositoryExclude.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries);
|
var reposToExclude = repositoryExclude.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries);
|
||||||
reposToBuild = reposToBuild.Except(reposToExclude);
|
reposToBuild = reposToBuild.Except(reposToExclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reposToBuild.ToList();
|
return reposToBuild.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,18 @@ namespace PinVersion
|
||||||
{
|
{
|
||||||
public void Main(string[] args)
|
public void Main(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length != 2)
|
if (args.Length != 3)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("Usage <repository-path> <package source>");
|
Console.Error.WriteLine("Usage <repository-path> <package source> <Korebuild Version>");
|
||||||
}
|
}
|
||||||
|
|
||||||
var repositoryPath = args[0];
|
var repositoryPath = args[0];
|
||||||
var packageSource = args[1];
|
var packageSource = args[1];
|
||||||
|
var korebuildVersion = args[2];
|
||||||
|
|
||||||
var packageRepository = PackageRepositoryFactory.Default.CreateRepository(packageSource);
|
var packageRepository = PackageRepositoryFactory.Default.CreateRepository(packageSource);
|
||||||
|
|
||||||
|
// Pin project.json files
|
||||||
foreach (var file in Directory.EnumerateFiles(repositoryPath, "project.json", SearchOption.AllDirectories))
|
foreach (var file in Directory.EnumerateFiles(repositoryPath, "project.json", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
var projectJson = JObject.Parse(File.ReadAllText(file));
|
var projectJson = JObject.Parse(File.ReadAllText(file));
|
||||||
|
|
@ -69,6 +71,35 @@ namespace PinVersion
|
||||||
projectJson.WriteTo(fileWriter);
|
projectJson.WriteTo(fileWriter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pin the build scripts
|
||||||
|
//TODO: handle build.sh files too
|
||||||
|
var dnxPackageName = "dnx-clr-win-x86";
|
||||||
|
var dnxPackage = packageRepository.FindPackage(dnxPackageName);
|
||||||
|
if (dnxPackage == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
$"Could not find the DNX package with name '{dnxPackageName}' to " +
|
||||||
|
"pin the build script");
|
||||||
|
}
|
||||||
|
|
||||||
|
var buildCmdFiles = Directory.GetFiles(repositoryPath, "build.cmd", SearchOption.TopDirectoryOnly);
|
||||||
|
if (buildCmdFiles == null || buildCmdFiles.Length == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"No build.cmd files found at {repositoryPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var buildCmdFile = buildCmdFiles[0];
|
||||||
|
var buildCmdFileContent = File.ReadAllText(buildCmdFile);
|
||||||
|
buildCmdFileContent = buildCmdFileContent.Replace(
|
||||||
|
"SET BUILDCMD_KOREBUILD_VERSION=\"\"",
|
||||||
|
$"SET BUILDCMD_KOREBUILD_VERSION={korebuildVersion}");
|
||||||
|
buildCmdFileContent = buildCmdFileContent.Replace(
|
||||||
|
"SET BUILDCMD_DNX_VERSION=\"\"",
|
||||||
|
$"SET BUILDCMD_DNX_VERSION={dnxPackage.Version.ToNormalizedString()}");
|
||||||
|
|
||||||
|
// Replace all content of the file
|
||||||
|
File.WriteAllText(buildCmdFile, buildCmdFileContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue