Skip to content

Commit

Permalink
Merge branch 'master' into Fix.Windows7
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardog authored Feb 20, 2023
2 parents b5d7c55 + 1f4c272 commit 7fe26a0
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 68 deletions.
8 changes: 2 additions & 6 deletions build/06-release-Nuget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ if ($env:version) {
"- Cleaning Nuget template folder"
git clean .\Build\Nuget\gsudo -xf

"- Generate gsudo.nuspec"
(Get-Content Build\Nuget\gsudo.nuspec.template) -replace '#VERSION#', "$version" | Out-File -encoding UTF8 .\Build\Nuget\gsudo.nuspec


"- Packing v$version to nuget"
mkdir Artifacts\Nuget -Force > $null
& nuget pack .\Build\Nuget\gsudo.nuspec -OutputDirectory "$((get-item Artifacts\Nuget).FullName)" || $(throw "Nuget pack failed.")
dotnet build .\Build\Nuget\gsudo.csproj /p:Version=$version -o artifacts\Nuget || $(throw "Nuget pack failed.")

"`n- Uploading v$version to Nuget"
gi "artifacts\nuget\gsudo.$($version).nupkg" || $(throw "Nuget push failed.")
nuget push artifacts\nuget\gsudo.$($version).nupkg -Source https://api.nuget.org/v3/index.json || $(throw "Nuget push failed.")


Expand Down
40 changes: 40 additions & 0 deletions build/Nuget/gsudo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack">

<PropertyGroup>
<Version>1.0.0.0</Version>
<Company>Gerardo Grignoli</Company>
<Authors>Gerardo Grignoli</Authors>
<PackageId>gsudo</PackageId>
<PackageTags>gsudo;sudo;runas</PackageTags>
<Description>gsudo is a sudo for Windows, allows to run commands with elevated permissions in the current console.</Description>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<NoBuild>true</NoBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeSymbols>false</IncludeSymbols>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackFrameworkReferences>false</PackFrameworkReferences>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<Copyright>Gerardo Grignoli and GitHub Contributors</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/gerardog/gsudo</PackageProjectUrl>
<RepositoryUrl>https://github.com/gerardog/gsudo</RepositoryUrl>
<RepositoryType>GIT</RepositoryType>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)\..\..\artifacts\net46-AnyCpu\gsudo.exe" Pack="true">
<PackagePath>runtimes\win-anycpu\native\gsudo.exe</PackagePath>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\..\artifacts\x86\gsudo.exe" Pack="true">
<PackagePath>runtimes\win-x86\native\gsudo.exe</PackagePath>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\..\artifacts\x64\gsudo.exe" Pack="true">
<PackagePath>runtimes\win-x64\native\gsudo.exe</PackagePath>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\..\artifacts\arm64\gsudo.exe" Pack="true">
<PackagePath>runtimes\win-arm64\native\gsudo.exe</PackagePath>
</Content>
<Content Include="gsudo.targets" PackagePath="build/gsudo.targets" Pack="true" />
</ItemGroup>

</Project>
56 changes: 0 additions & 56 deletions build/Nuget/gsudo.nuspec.template

This file was deleted.

33 changes: 33 additions & 0 deletions build/Nuget/gsudo.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)\..\runtimes\win-anycpu\native\gsudo.exe">
<Link>gsudo.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\runtimes\win-x86\native\gsudo.exe">
<Link>runtimes\win-x86\native\gsudo.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\runtimes\win-x64\native\gsudo.exe">
<Link>runtimes\win-x64\native\gsudo.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\runtimes\win-arm64\native\gsudo.exe">
<Link>runtimes\win-arm64\native\gsudo.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<Pack>false</Pack>
</Content>
</ItemGroup>
</Project>
58 changes: 58 additions & 0 deletions src/gsudo.Wrappers/gsudoModule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,64 @@ $c += "}"
iex ($c -join "`n" | Out-String)

function gsudo {
<#
.SYNOPSIS
Runs a command/scriptblock with elevated permissions. If no command is specified, it starts an elevated Powershell session.
.DESCRIPTION
This function will attempt to retrieve a matching registry key for an
already installed application, usually to be used with a
chocolateyUninstall.ps1 automation script.
The function also prevents `Get-ItemProperty` from failing when
handling wrongly encoded registry keys.
.NOTES
Available in 0.9.10+. If you need to maintain compatibility with pre
0.9.10, please add the following to your nuspec (check for minimum
version):
~~~xml
<dependencies>
<dependency id="chocolatey-core.extension" version="1.1.0" />
</dependencies>
~~~
.INPUTS
String
.OUTPUTS
This function searches registry objects and returns an array
of PSCustomObject with the matched key's properties.
Retrieve properties with dot notation, for example:
`$key.UninstallString`
.EXAMPLE
>
# Version match: Software name is "Gpg4Win (2.3.0)"
[array]$key = Get-UninstallRegistryKey -SoftwareName "Gpg4win (*)"
$key.UninstallString
.EXAMPLE
>
# Fuzzy match: Software name is "Launchy 2.5"
[array]$key = Get-UninstallRegistryKey -SoftwareName "Launchy*"
$key.UninstallString
.EXAMPLE
>
# Exact match: Software name in Programs and Features is "VLC media player"
[array]$key = Get-UninstallRegistryKey -SoftwareName "VLC media player"
$key.UninstallString
.EXAMPLE
>
# Elevate your current shell
gsudo
#>

$invocationLine = $MyInvocation.Line -replace "^$($MyInvocation.InvocationName)\s+" # -replace '"','""'

if ($invocationLine -match "(^| )!!( |$)")
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4309,9 +4309,9 @@ htmlparser2@^8.0.1:
entities "^4.3.0"

http-cache-semantics@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390"
integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==
version "4.1.1"
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a"
integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==

http-deceiver@^1.2.7:
version "1.2.7"
Expand Down Expand Up @@ -6997,9 +6997,9 @@ typedarray-to-buffer@^3.1.5:
is-typedarray "^1.0.0"

ua-parser-js@^0.7.30:
version "0.7.32"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.32.tgz#cd8c639cdca949e30fa68c44b7813ef13e36d211"
integrity sha512-f9BESNVhzlhEFf2CHMSj40NWOjYPl1YKYbrvIr/hFTDEmLq7SRbWvm7FcdcpCYT95zrOhC7gZSxjdnnTpBcwVw==
version "0.7.33"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532"
integrity sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw==

unherit@^1.0.4:
version "1.1.3"
Expand Down

0 comments on commit 7fe26a0

Please sign in to comment.