From 4699b429df1b8c390e7b61ca14bbc7d11832e928 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Fri, 24 May 2024 00:03:43 +0200 Subject: [PATCH] GitHubSync update --- .github/workflows/build-and-test.yml | 2 +- .github/workflows/dependabot-auto-merge.yml | 2 +- deployment/cake/components-tasks.cake | 13 +++++ deployment/cake/lib-generic.cake | 63 +++++++++++++++++++++ deployment/cake/lib-msbuild.cake | 10 ++-- deployment/cake/sourcecontrol-github.cake | 2 +- src/Directory.Build.shared.explicit.props | 5 ++ 7 files changed, 89 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 975a4ba..7843928 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -16,7 +16,7 @@ jobs: runs-on: windows-latest # Required for some (WPF) projects steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 id: checkout with: fetch-depth: 0 diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index cea481b..5214c1e 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Dependabot metadata id: dependabot-metadata - uses: dependabot/fetch-metadata@0fb21704c18a42ce5aa8d720ea4b912f5e6babef #2.0.0 + uses: dependabot/fetch-metadata@5e5f99653a5b510e8555840e80cbf1514ad4af38 #2.1.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Approve Dependabot PR diff --git a/deployment/cake/components-tasks.cake b/deployment/cake/components-tasks.cake index 9089131..ca91e6f 100644 --- a/deployment/cake/components-tasks.cake +++ b/deployment/cake/components-tasks.cake @@ -190,8 +190,10 @@ public class ComponentsProcessor : ProcessorBase // Special exception for Blazor projects var isBlazorProject = IsBlazorProject(BuildContext, component); + var isPackageContainerProject = IsPackageContainerProject(BuildContext, component); BuildContext.CakeContext.LogSeparator("Packaging component '{0}'", component); + CakeContext.Information("IsPackageContainerProject = '{0}'", isPackageContainerProject); var projectDirectory = GetProjectDirectory(component); var projectFileName = GetProjectFileName(BuildContext, component); @@ -287,6 +289,17 @@ public class ComponentsProcessor : ProcessorBase noBuild = false; } + if (isPackageContainerProject) + { + // In debug / local builds, automatic building of reference projects + // is enabled for convenience. If that is the case, noBuild must be + // set to false, but *only* in debug mode + if (BuildContext.General.IsLocalBuild) + { + noBuild = false; + } + } + // As described in the this issue: https://github.com/NuGet/Home/issues/4360 // we should not use IsTool, but set BuildOutputTargetFolder instead msBuildSettings.WithProperty("CopyLocalLockFileAssemblies", "true"); diff --git a/deployment/cake/lib-generic.cake b/deployment/cake/lib-generic.cake index d0a5fc9..7ab6571 100644 --- a/deployment/cake/lib-generic.cake +++ b/deployment/cake/lib-generic.cake @@ -440,6 +440,35 @@ private static bool IsCppProject(string projectName) return projectName.EndsWith(".vcxproj"); } +//-------------------------------------------------------------- + +private static bool IsPackageContainerProject(BuildContext buildContext, string projectName) +{ + var isPackageContainer = false; + + var projectFileName = CreateInlinedProjectXml(buildContext, projectName); + + var projectFileContents = System.IO.File.ReadAllText(projectFileName); + + var xmlDocument = XDocument.Parse(projectFileContents); + var projectElement = xmlDocument.Root; + + foreach (var propertyGroupElement in projectElement.Elements("PropertyGroup")) + { + var packageContainerElement = propertyGroupElement.Element("PackageContainer"); + if (packageContainerElement != null) + { + if (packageContainerElement.Value.ToLower() == "true") + { + isPackageContainer = true; + } + break; + } + } + + return isPackageContainer; +} + //------------------------------------------------------------- private static bool IsBlazorProject(BuildContext buildContext, string projectName) @@ -595,6 +624,40 @@ private static bool ShouldProcessProject(BuildContext buildContext, string proje return true; } +private static string CreateInlinedProjectXml(BuildContext buildContext, string projectName) +{ + buildContext.CakeContext.Information($"Running 'msbuild /pp' for project '{projectName}'"); + + var projectInlinedFileName = System.IO.Path.Combine(GetProjectOutputDirectory(buildContext, projectName), + "..", $"{projectName}.inlined.xml"); + + // Note: disabled caching until we correctly clean up everything + //if (!buildContext.CakeContext.FileExists(projectInlinedFileName)) + { + // Run "msbuild /pp" to create a single project file + + var msBuildSettings = new MSBuildSettings + { + Verbosity = Verbosity.Quiet, + ToolVersion = MSBuildToolVersion.Default, + Configuration = buildContext.General.Solution.ConfigurationName, + MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform + PlatformTarget = PlatformTarget.MSIL + }; + + ConfigureMsBuild(buildContext, msBuildSettings, projectName, "pp"); + + msBuildSettings.Target = string.Empty; + msBuildSettings.ArgumentCustomization = args => args.Append($"/pp:{projectInlinedFileName}"); + + var projectFileName = GetProjectFileName(buildContext, projectName); + + RunMsBuild(buildContext, projectName, projectFileName, msBuildSettings, "pp"); + } + + return projectInlinedFileName; +} + //------------------------------------------------------------- private static List GetProjectRuntimesIdentifiers(BuildContext buildContext, Cake.Core.IO.FilePath solutionOrProjectFileName, List runtimeIdentifiersToInvestigate) diff --git a/deployment/cake/lib-msbuild.cake b/deployment/cake/lib-msbuild.cake index ec71055..636c004 100644 --- a/deployment/cake/lib-msbuild.cake +++ b/deployment/cake/lib-msbuild.cake @@ -1,5 +1,5 @@ -#addin "nuget:?package=Cake.Issues&version=4.1.0" -#addin "nuget:?package=Cake.Issues.MsBuild&version=4.1.0" +#addin "nuget:?package=Cake.Issues&version=4.4.0" +#addin "nuget:?package=Cake.Issues.MsBuild&version=4.4.0" #tool "nuget:?package=MSBuild.Extension.Pack&version=1.9.1" @@ -67,7 +67,7 @@ private static void ConfigureMsBuild(BuildContext buildContext, MSBuildSettings } else { - buildContext.CakeContext.Information("This is a local build, disabling building of project references"); + buildContext.CakeContext.Information("This is a local build, not disabling building of project references"); } // Continuous integration build @@ -154,7 +154,7 @@ private static void ConfigureMsBuildForDotNet(BuildContext buildContext, DotNetM } else { - buildContext.CakeContext.Information($"This is a local build, disabling building of project references"); + buildContext.CakeContext.Information($"This is a local build, not disabling building of project references"); } // Continuous integration build @@ -488,4 +488,4 @@ private static void InjectAssemblySearchPathsInProjectFile(BuildContext buildCon { buildContext.CakeContext.Error($"Failed to process assembly search paths for project '{projectFileName}': {ex.Message}"); } -} \ No newline at end of file +} diff --git a/deployment/cake/sourcecontrol-github.cake b/deployment/cake/sourcecontrol-github.cake index a481e84..d2478d1 100644 --- a/deployment/cake/sourcecontrol-github.cake +++ b/deployment/cake/sourcecontrol-github.cake @@ -1,5 +1,5 @@ #addin "nuget:?package=Cake.GitHub&version=0.1.0" -#addin "nuget:?package=Octokit&version=10.0.0" +#addin "nuget:?package=Octokit&version=11.0.1" //------------------------------------------------------------- diff --git a/src/Directory.Build.shared.explicit.props b/src/Directory.Build.shared.explicit.props index 66f893c..01dc5af 100644 --- a/src/Directory.Build.shared.explicit.props +++ b/src/Directory.Build.shared.explicit.props @@ -50,6 +50,11 @@ bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + + + false + +