-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Samir Boulema
committed
Nov 11, 2021
1 parent
f76d70b
commit 4bbc45b
Showing
13 changed files
with
196 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: RunAsAdmin | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- 'feature/**' | ||
|
||
env: | ||
version: '2.0.${{ github.run_number }}' | ||
repoUrl: ${{ github.server_url }}/${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Update Assembly Version | ||
uses: dannevesdantas/[email protected] | ||
with: | ||
version: ${{ env.version }} | ||
|
||
- name: Update Vsix Version | ||
uses: cezarypiatek/[email protected] | ||
with: | ||
version: ${{ env.version }} | ||
vsix-manifest-file: 'TGit\source.extension.vsixmanifest' | ||
|
||
- name: Setup MSBuild | ||
uses: microsoft/[email protected] | ||
|
||
- name: NuGet restore | ||
run: nuget restore RunAsAdmin.sln | ||
|
||
- name: Build VSIX | ||
run: msbuild RunAsAdmin.sln /t:Rebuild /p:Configuration=Release | ||
env: | ||
DeployExtension: False | ||
|
||
- name: Publish Build Artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: RunAsAdmin | ||
path: | | ||
**\*.vsix | ||
publish-manifest.json | ||
readme.md | ||
release: | ||
name: Release | ||
needs: build | ||
runs-on: windows-latest | ||
environment: Release | ||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: Tag release | ||
id: tag_release | ||
uses: mathieudutour/[email protected] | ||
with: | ||
custom_tag: '${{ env.version }}' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create a GitHub release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ steps.tag_release.outputs.new_tag }} | ||
name: ${{ steps.tag_release.outputs.new_tag }} | ||
body: ${{ steps.tag_release.outputs.changelog }} | ||
artifacts: "**/*.vsix" | ||
|
||
- name: Publish to Marketplace | ||
uses: cezarypiatek/[email protected] | ||
with: | ||
extension-file: RunAsAdmin/RunAsAdmin/release/RunAsAdmin.vsix | ||
publish-manifest-file: RunAsAdmin/publish-manifest.json | ||
personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }} | ||
|
||
- name: Publish to Open VSIX Gallery | ||
uses: leandro-hermes/[email protected] | ||
with: | ||
host: 'www.vsixgallery.com' | ||
path: '/api/upload?repo=${{ env.repoUrl }}&issuetracker=${{ env.repoUrl }}/issues' | ||
https: true | ||
filePath: RunAsAdmin/RunAsAdmin/bin/release/RunAsAdmin.vsix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Community.VisualStudio.Toolkit; | ||
using Microsoft.VisualStudio.Setup.Configuration; | ||
using Microsoft.Win32; | ||
using System; | ||
using System.ComponentModel; | ||
using System.IO; | ||
|
||
namespace SamirBoulema.RunAsAdmin | ||
{ | ||
internal partial class OptionsProvider | ||
{ | ||
public class GeneralOptions : BaseOptionPage<General> { } | ||
} | ||
|
||
public class General : BaseOptionModel<General> | ||
{ | ||
private const string RegistryFolder = | ||
@"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\"; | ||
private const string VSLauncherInstallationPath = @"C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe"; | ||
private readonly string _installationPath = GetVisualStudioInstallationPath(); | ||
|
||
[Category("RunAsAdmin")] | ||
[DisplayName(@"Enabled")] | ||
[Description("Run Visual Studio as administrator. Restart Visual Studio for the applied changes to take effect")] | ||
public bool Enabled | ||
{ | ||
get => IsAdminEnabled(); | ||
set => RunAsAdmin(value); | ||
} | ||
|
||
private void RunAsAdmin(bool enable) | ||
{ | ||
Registry.SetValue(RegistryFolder, _installationPath, enable ? "RUNASADMIN" : "RUNASNORMAL"); | ||
Registry.SetValue(RegistryFolder, VSLauncherInstallationPath, enable ? "RUNASADMIN" : "RUNASNORMAL"); | ||
} | ||
|
||
private bool IsAdminEnabled() | ||
{ | ||
var runAsAdminKeyDevEnv = Registry.GetValue(RegistryFolder, _installationPath, null) as string; | ||
|
||
return runAsAdminKeyDevEnv?.Equals("RUNASADMIN") == true; | ||
} | ||
|
||
private static string GetVisualStudioInstallationPath() | ||
{ | ||
var config = (ISetupConfiguration2) | ||
Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D"))); | ||
var instance = config.GetInstanceForCurrentProcess(); | ||
|
||
var installationFolder = instance.GetInstallationPath(); | ||
|
||
return Path.Combine(installationFolder, @"Common7\IDE\devenv.exe"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,18 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Resources; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("RunAsAdmin")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Funda Real Estate B.V.")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("RunAsAdmin")] | ||
[assembly: AssemblyCopyright("")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: ComVisible(false)] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: ComVisible(false)] | ||
[assembly: CLSCompliant(false)] | ||
[assembly: NeutralResourcesLanguage("en-US")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Revision and Build Numbers | ||
// by using the '*' as shown below: | ||
|
||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
|
||
|
||
|
||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.