Skip to content

Commit

Permalink
Temp switch powershell reference packages
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCakeIsNaOH committed Jun 7, 2024
1 parent 0bc08c6 commit 265a80b
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 28 deletions.
4 changes: 2 additions & 2 deletions recipe.cake
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ Task("Prepare-Chocolatey-Packages")
StartProcess(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe", new ProcessSettings{ Arguments = "unpackself -f -y --allow-unofficial-build --run-actual" });
// Copy Chocolatey.PowerShell.dll and its help.xml file
CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/Chocolatey.PowerShell/net8.0/Chocolatey.PowerShell.dll", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/helpers/Chocolatey.PowerShell.dll");
CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/Chocolatey.PowerShell/net8.0/Chocolatey.PowerShell.dll-help.xml", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/helpers/Chocolatey.PowerShell.dll-help.xml");
CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/Chocolatey.PowerShell/net461/Chocolatey.PowerShell.dll", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/helpers/Chocolatey.PowerShell.dll");
CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/Chocolatey.PowerShell/net461/Chocolatey.PowerShell.dll-help.xml", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/helpers/Chocolatey.PowerShell.dll-help.xml");
// Tidy up logs and config folder which are not required
var logsDirectory = BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/logs";
Expand Down
7 changes: 2 additions & 5 deletions src/Chocolatey.PowerShell/Chocolatey.PowerShell.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net461</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<WarningsAsErrors>CA1416</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseOfficial|AnyCPU' or '$(Configuration)|$(Platform)' == 'ReleaseOfficialNo7zip|AnyCPU'">
<OutputPath>bin\ReleaseOfficial\</OutputPath>
Expand All @@ -22,8 +21,6 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.2" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="PowerShellStandard.Library" Version="3.0.0-preview-02" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public sealed class GetEnvironmentVariableCommand : ChocolateyCmdlet
// Avoid logging environment variable names by accident.
protected override bool Logging { get; } = false;

[SupportedOSPlatform("windows")]

protected override void End()
{
if (PreserveVariables)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class GetEnvironmentVariableNamesCommand : ChocolateyCmdlet
// Do not log function call
protected override bool Logging { get; } = false;

[SupportedOSPlatform("windows")]

protected override void End()
{
WriteObject(EnvironmentHelper.GetVariableNames(Scope));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class InstallChocolateyPathCommand : ChocolateyCmdlet
[Alias("Scope", "Type")]
public EnvironmentVariableTarget PathType { get; set; } = EnvironmentVariableTarget.User;

[SupportedOSPlatform("windows")]

protected override void End()
{
Paths.InstallPathEntry(this, Path, PathType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public sealed class SetEnvironmentVariableCommand : ChocolateyCmdlet
[Parameter(Position = 2)]
public EnvironmentVariableTarget Scope { get; set; }

[SupportedOSPlatform("windows")]

protected override void End()
{
EnvironmentHelper.SetVariable(this, Name, Scope, Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class UninstallChocolateyPathCommand : ChocolateyCmdlet
[Alias("Scope", "Type")]
public EnvironmentVariableTarget PathType { get; set; } = EnvironmentVariableTarget.User;

[SupportedOSPlatform("windows")]

protected override void End()
{
Paths.UninstallPathEntry(this, Path, PathType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Chocolatey.PowerShell.Commands
[OutputType(typeof(void))]
public sealed class UpdateSessionEnvironmentCommand : ChocolateyCmdlet
{
[SupportedOSPlatform("windows")]

protected override void End()
{
var calledByAlias = MyInvocation?.InvocationName.ToLower() == "refreshenv";
Expand Down
11 changes: 5 additions & 6 deletions src/Chocolatey.PowerShell/Helpers/EnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static class EnvironmentHelper
/// <param name="name">The name of the environment variable to retrieve.</param>
/// <param name="scope">The scope to look in for the environment variable.</param>
/// <returns>The value of the environment variable as a string.</returns>
[SupportedOSPlatform("windows")]

public static string GetVariable(PSCmdlet cmdlet, string name, EnvironmentVariableTarget scope)
{
return GetVariable(cmdlet, name, scope, preserveVariables: false);
Expand All @@ -51,7 +51,7 @@ public static string GetVariable(PSCmdlet cmdlet, string name, EnvironmentVariab
/// <param name="scope">The scope to look in for the environment variable.</param>
/// <param name="preserveVariables">Whether to preserve environment variable names in the retrieved value. If false, environment names will be expanded.</param>
/// <returns>The value of the environment variable as a string.</returns>
[SupportedOSPlatform("windows")]

public static string GetVariable(PSCmdlet cmdlet, string name, EnvironmentVariableTarget scope, bool preserveVariables)
{
if (scope == EnvironmentVariableTarget.Process)
Expand Down Expand Up @@ -91,7 +91,7 @@ public static string GetVariable(PSCmdlet cmdlet, string name, EnvironmentVariab
/// <param name="scope">The scope of the environment variables to look up.</param>
/// <returns>The registry key associated with the targeted <paramref name="scope"/> of environment variables.</returns>
/// <exception cref="NotSupportedException">Thrown if <paramref name="scope"/> is not <see cref="EnvironmentVariableTarget.User"/> or <see cref="EnvironmentVariableTarget.Machine"/>.</exception>
[SupportedOSPlatform("windows")]

private static RegistryKey GetEnvironmentKey(EnvironmentVariableTarget scope, bool writable = false)
{
switch (scope)
Expand All @@ -111,7 +111,7 @@ private static RegistryKey GetEnvironmentKey(EnvironmentVariableTarget scope, bo
/// </summary>
/// <param name="scope">The scope to lookup environment variable names in.</param>
/// <returns></returns>
[SupportedOSPlatform("windows")]

public static string[] GetVariableNames(EnvironmentVariableTarget scope)
{
if (scope == EnvironmentVariableTarget.Process)
Expand Down Expand Up @@ -140,7 +140,6 @@ public static string[] GetVariableNames(EnvironmentVariableTarget scope)
/// <param name="name">The name of the environment variable to set.</param>
/// <param name="scope">The scope to set the environment variable in.</param>
/// <param name="value">The value to set the environment variable to.</param>
[SupportedOSPlatform("windows")]
public static void SetVariable(PSCmdlet cmdlet, string name, EnvironmentVariableTarget scope, string value)
{
if (scope == EnvironmentVariableTarget.Process)
Expand Down Expand Up @@ -211,7 +210,7 @@ public static void SetVariable(PSCmdlet cmdlet, string name, EnvironmentVariable
/// Updates the current session environment, ensuring environment changes are reflected in the current session.
/// </summary>
/// <param name="cmdlet">The cmdlet calling the method.</param>
[SupportedOSPlatform("windows")]

public static void UpdateSession(PSCmdlet cmdlet)
{
var userName = GetVariable(cmdlet, EnvironmentVariables.Username, EnvironmentVariableTarget.Process);
Expand Down
4 changes: 2 additions & 2 deletions src/Chocolatey.PowerShell/Helpers/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ internal static string GetPathString(IList<string> paths)
/// <param name="cmdlet">The cmdlet running the method.</param>
/// <param name="pathEntry">The path entry to add/install.</param>
/// <param name="scope">The target scope of the PATH variable to modify.</param>
[SupportedOSPlatform("windows")]

public static void InstallPathEntry(PSCmdlet cmdlet, string pathEntry, EnvironmentVariableTarget scope)
{
var pathEntries = new List<string>(ParsePathString(EnvironmentHelper.GetVariable(cmdlet, EnvironmentVariables.Path, scope, preserveVariables: true)));
Expand Down Expand Up @@ -138,7 +138,7 @@ void updatePath()
/// <param name="cmdlet">The cmdlet running the method.</param>
/// <param name="pathEntry">The path entry to remove/uninstall.</param>
/// <param name="scope">The target scope of the PATH variable to modify.</param>
[SupportedOSPlatform("windows")]

public static void UninstallPathEntry(PSCmdlet cmdlet, string pathEntry, EnvironmentVariableTarget scope)
{
var pathEntries = new List<string>(ParsePathString(EnvironmentHelper.GetVariable(cmdlet, EnvironmentVariables.Path, scope, preserveVariables: true)));
Expand Down
5 changes: 0 additions & 5 deletions src/Chocolatey.PowerShell/Helpers/ProcessInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public static bool IsWindows()
/// <returns>True if running on Windows and the process has administrative rights.</returns>
public static bool IsElevated()
{
if (!OperatingSystem.IsWindows())
{
return false;
}

using (var identity = WindowsIdentity.GetCurrent(TokenAccessLevels.Query | TokenAccessLevels.Duplicate))
{
if (identity is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
<WarningsAsErrors>CA1416</WarningsAsErrors>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\Debug\</OutputPath>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoResources|AnyCPU'">
<OutputPath>bin\NoResources\</OutputPath>
<Optimize>true</Optimize>
Expand All @@ -19,6 +21,11 @@
<Optimize>true</Optimize>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<Optimize>true</Optimize>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<None Include="context\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
9 changes: 8 additions & 1 deletion src/chocolatey.tests/chocolatey.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoResources|AnyCPU'">
<OutputPath>bin\NoResources\</OutputPath>
<Optimize>true</Optimize>
Expand All @@ -18,11 +21,15 @@
<Optimize>true</Optimize>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<Optimize>true</Optimize>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Build" />
Expand Down

0 comments on commit 265a80b

Please sign in to comment.