diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..396e7edb12 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} diff --git a/build/RepositoryBuild.targets b/build/RepositoryBuild.targets index 4ff447a430..2f92b51d9a 100644 --- a/build/RepositoryBuild.targets +++ b/build/RepositoryBuild.targets @@ -18,8 +18,6 @@ - - @@ -35,7 +33,6 @@ Artifacts="@(PinnedArtifactInfo)" Repository="%(RepositoryBuildOrder.Identity)" OutputPath="%(RepositoryBuildOrder.RepositoryPath)\build\dependencies.g.targets" - RestoreAdditionalSources="@(PinPackageSources)" UseFloatingVersions="false" Condition="'%(RepositoryBuildOrder.RepositoryPath)' != ''" BuildNumber="$(BuildNumber)" /> @@ -51,6 +48,7 @@ + $(RepositoryBuildArguments) /p:DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath) $(RepositoryBuildArguments) /p:DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath) $(RepositoryBuildArguments) /p:BuildNumber=$(BuildNumber) /p:Configuration=$(Configuration) /p:CommitHash=$(CommitHash) $(RepositoryBuildArguments) /noconsolelogger '/l:RepoTasks.FlowLogger,$(MSBuildThisFileDirectory)tasks\bin\publish\RepoTasks.dll;Summary;FlowId=$(RepositoryToBuild)' diff --git a/build/repo.targets b/build/repo.targets index 989af75856..fde013f088 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -20,10 +20,10 @@ $(IntermediateDir)ext\ $(IntermediateDir)dependencies.props + $(IntermediateDir)sources.props Patch20_ - $(PrepareDependsOn);CleanArtifacts;CleanUniverseArtifacts - $(CleanDependsOn);CleanUniverseArtifacts + $(CleanDependsOn);CleanArtifacts;CleanUniverseArtifacts $(RestoreDependsOn);RestoreExternalDependencies $(CompileDependsOn);CloneRepositories;BuildRepositories $(PackageDependsOn);SplitPackages @@ -42,17 +42,27 @@ DestinationFolder="$(IntermediateMirrorPackageDir)" /> - + <_LineupPackages Include="@(ExternalDependency)" /> <_LineupPackages Include="%(ArtifactInfo.PackageId)" Version="%(ArtifactInfo.Version)" Condition=" '%(ArtifactInfo.ArtifactType)' == 'NuGetPackage' " /> <_LineupPackages Include="%(ShippedArtifactInfo.PackageId)" Version="%(ShippedArtifactInfo.Version)" Condition=" '%(ShippedArtifactInfo.ArtifactType)' == 'NuGetPackage' " /> + + <_LineupSources Include="$(_DependencyPackagesDirectory)" Condition="'$(_DependencyPackagesDirectory)' != '' AND Exists('$(_DependencyPackagesDirectory)')" /> + <_LineupSources Include="$(BuildDir)" /> + <_LineupSources Include="$(IntermediateExternalPackageDir)" /> + <_LineupSources Include="$(IntermediateMirrorPackageDir)" /> + + + @@ -140,7 +150,7 @@ + DependsOnTargets="_PrepareRepositories;_CreateRepositoriesListWithCommits;GeneratePropsFiles;ComputeGraph;_BuildRepositories" /> - + + Properties="Configuration=$(Configuration);BuildNumber=$(BuildNumber);DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath)"> diff --git a/build/tasks/GenerateLineup.cs b/build/tasks/GenerateLineup.cs index d1114814b5..5053ebdfa2 100644 --- a/build/tasks/GenerateLineup.cs +++ b/build/tasks/GenerateLineup.cs @@ -25,9 +25,6 @@ namespace RepoTasks // Can be set to filter the lists of packages when produce a list for a specific repository public string Repository { get; set; } - // Items to add to the RestoreAdditionalProjectSources list in project - public ITaskItem[] RestoreAdditionalSources { get; set; } - public bool UseFloatingVersions { get; set; } public string BuildNumber { get; set; } @@ -43,16 +40,9 @@ namespace RepoTasks } var items = new XElement("ItemGroup"); - var props = new XElement("PropertyGroup"); - var root = new XElement("Project", props, items); + var root = new XElement("Project", items); var doc = new XDocument(root); - if (RestoreAdditionalSources?.Length > 0) - { - var sources = RestoreAdditionalSources.Aggregate("$(RestoreAdditionalProjectSources)", (sum, piece) => sum + ";" + piece.ItemSpec); - props.Add(new XElement("RestoreAdditionalProjectSources", sources)); - } - var packages = new List(); foreach (var pkg in Artifacts.Select(ArtifactInfo.Parse) diff --git a/build/tasks/GenerateRestoreSourcesPropsFile.cs b/build/tasks/GenerateRestoreSourcesPropsFile.cs new file mode 100644 index 0000000000..75343a16bc --- /dev/null +++ b/build/tasks/GenerateRestoreSourcesPropsFile.cs @@ -0,0 +1,52 @@ +// 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.Linq; +using System.IO; +using System.Text; +using System.Xml; +using System.Xml.Linq; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace RepoTasks +{ + public class GenerateRestoreSourcesPropsFile : Task + { + [Required] + public ITaskItem[] Sources { get; set; } + + [Required] + public string OutputPath { get; set; } + + public override bool Execute() + { + OutputPath = OutputPath.Replace('\\', '/'); + Directory.CreateDirectory(Path.GetDirectoryName(OutputPath)); + + var sources = new XElement("DotNetRestoreSources"); + var doc = new XDocument(new XElement("Project", new XElement("PropertyGroup", sources))); + + var sb = new StringBuilder(); + + foreach (var source in Sources) + { + sb.Append(source.ItemSpec).AppendLine(";"); + } + + sources.SetValue(sb.ToString()); + + var settings = new XmlWriterSettings + { + OmitXmlDeclaration = true, + }; + using (var writer = XmlWriter.Create(OutputPath, settings)) + { + Log.LogMessage(MessageImportance.High, $"Generate {OutputPath}"); + doc.Save(writer); + } + return !Log.HasLoggedErrors; + } + } +} diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks index da9cb26603..4990d23c33 100644 --- a/build/tasks/RepoTasks.tasks +++ b/build/tasks/RepoTasks.tasks @@ -8,5 +8,6 @@ +