Skip to content

Commit

Permalink
Merge pull request #3609 from gep13/issue-3591
Browse files Browse the repository at this point in the history
(#3591) Remove no7zip build tasks
  • Loading branch information
corbob authored Jan 28, 2025
2 parents c2636fb + 8e3baf9 commit c870ae6
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 298 deletions.
171 changes: 1 addition & 170 deletions recipe.cake
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,6 @@ Func<List<ILMergeConfig>> getILMergeConfigs = () =>
PrimaryAssemblyName = BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.dll",
AssemblyPaths = assembliesToILMerge });

if (DirectoryExists(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/"))
{
var no7zAssembliesToILMerge = GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/*.{exe|dll}")
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/choco.exe")
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/System.Management.Automation.dll")
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/chocolatey.tests*.dll")
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/{Moq|nunit|Should|testcentric}*.dll")
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/Chocolatey.PowerShell.dll");

Information("The following assemblies have been selected to be ILMerged for choco.exe No7zip Version...");
foreach (var assemblyToILMerge in no7zAssembliesToILMerge)
{
Information(assemblyToILMerge.FullPath);
}

mergeConfigs.Add(new ILMergeConfig() {
KeyFile = BuildParameters.StrongNameKeyPath,
LogFile = BuildParameters.Paths.Directories.Build + "/ilmerge-chocono7zipexe.log",
TargetPlatform = targetPlatform,
Target = "exe",
Internalize = BuildParameters.RootDirectoryPath + "/src/chocolatey.console/ilmerge.internalize.ignore.txt",
Output = BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip_merged/choco.exe",
PrimaryAssemblyName = BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/choco.exe",
AssemblyPaths = no7zAssembliesToILMerge });
}

return mergeConfigs;
};

Expand All @@ -93,11 +67,6 @@ Func<FilePathCollection> getScriptsToVerify = () =>
GetFiles(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/**/*.{ps1|psm1|psd1}") +
GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/**/*.{ps1|psm1|psd1}");

if (DirectoryExists(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip"))
{
scriptsToVerify += GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip/**/*.{ps1|psm1|psd1}");
}

Information("The following PowerShell scripts have been selected to be verified...");
foreach (var scriptToVerify in scriptsToVerify)
{
Expand Down Expand Up @@ -129,14 +98,6 @@ Func<FilePathCollection> getFilesToSign = () =>
+ GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/redirects/*.exe")
+ GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/helpers/Chocolatey.PowerShell.dll");

if (DirectoryExists(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip"))
{
filesToSign += GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip/tools/chocolateyInstall/choco.exe")
+ GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip/tools/chocolateyInstall/tools/{checksum|shimgen}.exe")
+ GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip/tools/chocolateyInstall/redirects/*.exe")
+ GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip/tools/chocolateyInstall/helpers/Chocolatey.PowerShell.dll");
}

Information("The following assemblies have been selected to be signed...");
foreach (var fileToSign in filesToSign)
{
Expand Down Expand Up @@ -215,136 +176,6 @@ Task("Prepare-Chocolatey-Packages")
}
});

Task("Build-ChocolateyNo7zip")
.WithCriteria(() => BuildParameters.Configuration == "ReleaseOfficial", "Skipping No7zip because this isn't an official release")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependeeOf("Run-ILMerge")
.Does<BuildData>(data => RequireTool(ToolSettings.MSBuildExtensionPackTool, () =>
{
Information("Building {0} with No7zip", BuildParameters.SolutionFilePath);

CleanDirectory(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/");

var no7zLogPath = BuildParameters.Paths.Files.BuildLogFilePath.ToString().Replace("\\.(\\S+)$", "-no7zip.${1}");

if (BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows)
{
var msbuildSettings = new MSBuildSettings()
{
ToolPath = ToolSettings.MSBuildToolPath
}
.SetPlatformTarget(ToolSettings.BuildPlatformTarget)
.UseToolVersion(ToolSettings.BuildMSBuildToolVersion)
.WithProperty("OutputPath", MakeAbsolute(new DirectoryPath(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/")).FullPath)
.WithProperty("TreatWarningsAsErrors", BuildParameters.TreatWarningsAsErrors.ToString())
.WithTarget("Build")
.SetMaxCpuCount(ToolSettings.MaxCpuCount)
.SetConfiguration("ReleaseOfficialNo7zip")
.WithLogger(
Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath,
"XmlFileLogger",
string.Format(
"logfile=\"{0}\";invalidCharReplacement=_;verbosity=Detailed;encoding=UTF-8",
no7zLogPath
)
);

MSBuild(BuildParameters.SolutionFilePath, msbuildSettings);
}

if (FileExists(no7zLogPath))
{
BuildParameters.BuildProvider.UploadArtifact(no7zLogPath);
}
}));

Task("Prepare-ChocolateyNo7zip-Package")
.WithCriteria(() => BuildParameters.Configuration == "ReleaseOfficial", "Skipping No7zip because this isn't an official release")
.WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping because not running on Windows")
.WithCriteria(() => BuildParameters.ShouldRunChocolatey, "Skipping because execution of Chocolatey has been disabled")
.IsDependentOn("Build-ChocolateyNo7zip")
.IsDependeeOf("Sign-Assemblies")
.IsDependeeOf("Verify-PowerShellScripts")
.IsDependeeOf("Create-ChocolateyNo7zip-Package")
.Does(() =>
{
var nuspecDirectory = BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip";
// Copy the Nuget/Chocolatey directory from Root Folder to temp/nuspec/chocolatey-no7zip
EnsureDirectoryExists(nuspecDirectory);
CopyFiles(GetFiles("./nuspec/chocolatey/**/*"), nuspecDirectory, true);

// Copy legal documents
CopyFile(BuildParameters.RootDirectoryPath + "/docs/legal/CREDITS.md", nuspecDirectory + "/tools/chocolateyInstall/CREDITS.txt");
CopyFile(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/LICENSE.txt", nuspecDirectory + "/tools/chocolateyInstall/LICENSE.txt");

// Copy choco.exe.manifest
CopyFile(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/choco.exe.manifest", nuspecDirectory + "/tools/chocolateyInstall/choco.exe.manifest");

// Copy external file resources
EnsureDirectoryExists(nuspecDirectory + "/tools/chocolateyInstall/helpers");
CopyFiles(GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/helpers/**/*"), nuspecDirectory + "/tools/chocolateyInstall/helpers", true);
EnsureDirectoryExists(nuspecDirectory + "/tools/chocolateyInstall/redirects");
CopyFiles(GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/redirects/**/*"), nuspecDirectory + "/tools/chocolateyInstall/redirects", true);
EnsureDirectoryExists(nuspecDirectory + "/tools/chocolateyInstall/tools");
CopyFiles(GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/tools/**/*"), nuspecDirectory + "/tools/chocolateyInstall/tools", true);

// Copy merged choco.exe
CopyFile(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip_merged/choco.exe", nuspecDirectory + "/tools/chocolateyInstall/choco.exe");

// Copy Chocolatey.PowerShell.dll and help.xml file
CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/Chocolatey.PowerShell/Chocolatey.PowerShell.dll", nuspecDirectory + "/tools/chocolateyInstall/helpers/Chocolatey.PowerShell.dll");
CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/Chocolatey.PowerShell/Chocolatey.PowerShell.dll-help.xml", nuspecDirectory + "/tools/chocolateyInstall/helpers/Chocolatey.PowerShell.dll-help.xml");

// Tidy up logs and config folder which are not required
var logsDirectory = nuspecDirectory + "/tools/chocolateyInstall/logs";
var configDirectory = nuspecDirectory + "/tools/chocolateyInstall/config";

if (DirectoryExists(logsDirectory))
{
DeleteDirectory(logsDirectory, new DeleteDirectorySettings {
Recursive = true,
Force = true
});
}

if (DirectoryExists(configDirectory))
{
DeleteDirectory(configDirectory, new DeleteDirectorySettings {
Recursive = true,
Force = true
});
}
});

Task("Create-ChocolateyNo7zip-Package")
.WithCriteria(() => BuildParameters.Configuration == "ReleaseOfficial", "Skipping No7zip because this isn't an official release")
.WithCriteria(() => BuildParameters.ShouldRunChocolatey, "Skipping because execution of Chocolatey has been disabled")
.WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping because not running on Windows")
.IsDependentOn("Prepare-ChocolateyNo7zip-Package")
.IsDependeeOf("Package")
.Does(() =>
{
var nuspecDirectory = BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "-no7zip/";
var nuspecFile = nuspecDirectory + "chocolatey.nuspec";

ChocolateyPack(nuspecFile, new ChocolateyPackSettings {
AllowUnofficial = true,
Version = BuildParameters.Version.PackageVersion,
OutputDirectory = nuspecDirectory,
WorkingDirectory = BuildParameters.Paths.Directories.PublishedApplications
});

MoveFile(
nuspecDirectory + "chocolatey." + BuildParameters.Version.PackageVersion + ".nupkg",
BuildParameters.Paths.Directories.ChocolateyPackages + "/chocolatey-no7zip." + BuildParameters.Version.PackageVersion + ".nupkg"
);

// Due to the fact that we have chosen to ignore the no7zip package via the chocolateyNupkgGlobbingPattern, it will
// no longer be automatically uploaded via Chocolatey.Cake.Recipe, so we need to handle that work here.
BuildParameters.BuildProvider.UploadArtifact(BuildParameters.Paths.Directories.ChocolateyPackages + "/chocolatey-no7zip." + BuildParameters.Version.PackageVersion + ".nupkg");
});

Task("Prepare-NuGet-Packages")
.WithCriteria(() => BuildParameters.ShouldRunNuGet, "Skipping because execution of NuGet has been disabled")
.IsDependeeOf("Create-NuGet-Packages")
Expand Down Expand Up @@ -441,7 +272,7 @@ BuildParameters.SetParameters(context: Context,
shouldRunNuGet: IsRunningOnWindows(),
shouldAuthenticodeSignPowerShellScripts: IsRunningOnWindows(),
shouldPublishAwsLambdas: false,
chocolateyNupkgGlobbingPattern: "/**/chocolatey[!-no7zip]*.nupkg");
chocolateyNupkgGlobbingPattern: "/**/chocolatey*.nupkg");

ToolSettings.SetToolSettings(context: Context);

Expand Down
2 changes: 1 addition & 1 deletion src/Chocolatey.PowerShell/Chocolatey.PowerShell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficial|AnyCPU' or '$(Configuration)|$(Platform)' == 'ReleaseOfficialNo7zip|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficial|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ReleaseOfficial\</OutputPath>
<DefineConstants>TRACE;FORCE_CHOCOLATEY_OFFICIAL_KEY</DefineConstants>
Expand Down
20 changes: 0 additions & 20 deletions src/chocolatey.console/chocolatey.console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,6 @@
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficialNo7zip|x86'">
<OutputPath>bin\x86\ReleaseOfficialNo7zip\</OutputPath>
<DefineConstants>TRACE;FORCE_CHOCOLATEY_OFFICIAL_KEY</DefineConstants>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<Optimize>true</Optimize>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficialNo7zip|AnyCPU'">
<OutputPath>bin\ReleaseOfficialNo7zip\</OutputPath>
<DefineConstants>TRACE;FORCE_CHOCOLATEY_OFFICIAL_KEY</DefineConstants>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<Optimize>true</Optimize>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<ItemGroup>
<Reference Include="AlphaFS, Version=2.1.0.0, Culture=neutral, PublicKeyToken=4d31a58f7d7ad5c9, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/chocolatey.resources/chocolatey.resources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficial|AnyCPU' or '$(Configuration)|$(Platform)' == 'ReleaseOfficialNo7zip|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficial|AnyCPU'">
<OutputPath>bin\ReleaseOfficial\</OutputPath>
<DefineConstants>TRACE;FORCE_CHOCOLATEY_OFFICIAL_KEY</DefineConstants>
<Optimize>true</Optimize>
Expand Down Expand Up @@ -235,7 +235,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' != 'ReleaseOfficialNo7zip'">
<ItemGroup>
<EmbeddedResource Include="tools\7z.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
Expand Down
Loading

0 comments on commit c870ae6

Please sign in to comment.