Skip to content

Commit

Permalink
Initial version of the program
Browse files Browse the repository at this point in the history
  • Loading branch information
samhocevar committed Oct 20, 2021
0 parents commit 5504a50
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Everything is text unless it isn’t
* text=auto

# This is really text
*.cs text
*.xaml text

# This is Windows-specific and should always have CRLF
*.sln text eol=crlf
*.csproj text eol=crlf
*.resx text eol=crlf
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.vs/
*.v12.suo
*.VC.db
*.VC.opendb
*.vcxproj.user
*.csproj.user

bin/
obj/
52 changes: 52 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using chocolatey;
using chocolatey.infrastructure.logging;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Security.Principal;

namespace install_chocolatey
{
class Program
{
static void Main(string[] args)
{
// If not running with elevated privileges, try to acquire them
var identity = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(identity);
if (!principal.IsInRole(WindowsBuiltInRole.Administrator))
{
Process p = new Process();
p.StartInfo.FileName = Assembly.GetExecutingAssembly().Location;
p.StartInfo.Verb = "runas"; // elevated privileges
p.StartInfo.UseShellExecute = true;
try
{
p.Start();
return;
}
catch
{
Console.WriteLine("Error: must be run as administrator");
}
}
else
{
// Set this environment variable to a sensible default value, otherwise chocolatey.lib will use the executable location
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ChocolateyInstall")))
Environment.SetEnvironmentVariable("ChocolateyInstall", @"C:\ProgramData\chocolatey");

var choco = Lets.GetChocolatey();
choco.SetCustomLogging(new NullLog());

choco.Set(conf => conf.CommandName = "upgrade");
choco.RunConsole(new string[] { "-y", "--force", "chocolatey" });
choco.RunConsole(new string[] { "-y", "--force", "chocolatey-gui" });

Console.Write("\n\nSetup was successful. Press any key to quit.\n");
}

Console.ReadKey();
}
}
}
32 changes: 32 additions & 0 deletions install-chocolatey.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{E0F8D1D0-B649-476B-860A-3D17D42475F9}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>install_chocolatey</RootNamespace>
<TargetFramework>net48</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AssemblyTitle>install-chocolatey</AssemblyTitle>
<Product>install-chocolatey</Product>
<Copyright>Copyright © 2021</Copyright>
<OutputPath>bin\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="chocolatey.lib" Version="0.11.2" />
<PackageReference Include="GitVersion.MsBuild" Version="5.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="log4net" Version="2.0.12" />
</ItemGroup>
</Project>
25 changes: 25 additions & 0 deletions install-chocolatey.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31729.503
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "install-chocolatey", "install-chocolatey.csproj", "{E0F8D1D0-B649-476B-860A-3D17D42475F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E0F8D1D0-B649-476B-860A-3D17D42475F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0F8D1D0-B649-476B-860A-3D17D42475F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0F8D1D0-B649-476B-860A-3D17D42475F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0F8D1D0-B649-476B-860A-3D17D42475F9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {040DE2E6-CBBE-43EC-88EB-2B64390F9752}
EndGlobalSection
EndGlobal

0 comments on commit 5504a50

Please sign in to comment.