Skip to content

Commit

Permalink
Updated to Visual Studio 2019.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlebansais committed Dec 17, 2019
1 parent 273a31c commit 1bc1ef5
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 41 deletions.
21 changes: 11 additions & 10 deletions CAcertInstall/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Localization;
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Windows;
Expand All @@ -17,7 +18,7 @@ public App()
string LanguageOption = "-Language=";
if (arg.Substring(0, LanguageOption.Length) == LanguageOption)
{
string LanguageString = arg.Substring(LanguageOption.Length).ToUpper();
string LanguageString = arg.Substring(LanguageOption.Length).ToUpper(CultureInfo.CurrentCulture);

if (LanguageString == "0409")
LocalizedString.CurrentLanguage = LocalizedString.Language.ENU;
Expand All @@ -28,30 +29,30 @@ public App()
}

X509Certificate2 x509certificateRoot = LoadCertificateFromResources("root.crt");
certificateRoot = new Certificate(x509certificateRoot, StoreName.Root);
CertificateRoot = new Certificate(x509certificateRoot, StoreName.Root);
X509Certificate2 x509certificateClass3 = LoadCertificateFromResources("class3.crt");
certificateClass3 = new Certificate(x509certificateClass3, StoreName.CertificateAuthority);
CertificateClass3 = new Certificate(x509certificateClass3, StoreName.CertificateAuthority);

if (CertificateStore.IsCertificateInstalled(certificateRoot) && CertificateStore.IsCertificateInstalled(certificateClass3))
if (CertificateStore.IsCertificateInstalled(CertificateRoot) && CertificateStore.IsCertificateInstalled(CertificateClass3))
Process.GetCurrentProcess().Kill();
}

public X509Certificate2 LoadCertificateFromResources(string Name)
public static X509Certificate2 LoadCertificateFromResources(string Name)
{
X509Certificate2 certificate = new X509Certificate2();
X509Certificate2 Certificate = new X509Certificate2();

using (Stream stream = ResourceAssembly.GetManifestResourceStream("CAcertInstall.Resources." + Name))
{
byte[] Data = new byte[stream.Length];
stream.Read(Data, 0, Data.Length);

certificate.Import(Data);
Certificate.Import(Data);
}

return certificate;
return Certificate;
}

public static Certificate certificateRoot;
public static Certificate certificateClass3;
public static Certificate CertificateRoot { get; private set; }
public static Certificate CertificateClass3 { get; private set; }
}
}
55 changes: 41 additions & 14 deletions CAcertInstall/CAcertInstall.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.6\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.6\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.6\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.6\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.6\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.6\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{16291F2B-D31A-4DA1-A4D9-DB6ECF49589E}</ProjectGuid>
Expand All @@ -11,8 +16,6 @@
<RootNamespace>CAcertInstall</RootNamespace>
<AssemblyName>CAcertInstall</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
Expand All @@ -31,6 +34,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup>
<StartupObject>CAcertInstall.App</StartupObject>
Expand All @@ -51,7 +56,7 @@
<ManifestCertificateThumbprint>1EF08ADFF8A71524E8E164A0DEA2B5C3B87CA54A</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>proengin.p12</ManifestKeyFile>
<NoWarn>CA1031;CA1062;CA5380</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -60,9 +65,8 @@
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<RunCodeAnalysis>true</RunCodeAnalysis>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -71,9 +75,7 @@
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down Expand Up @@ -130,6 +132,7 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -177,18 +180,42 @@
<ItemGroup>
<Resource Include="Resources\failure.ico" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\analyzers\dotnet\cs\Microsoft.CodeAnalysis.VersionCheckAnalyzer.resources.dll" />
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\analyzers\dotnet\cs\Microsoft.CodeAnalysis.VersionCheckAnalyzer.resources.dll" />
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.6\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PostBuildEvent>if exist "$(SolutionDir)signfile.bat" call "$(SolutionDir)signfile.bat" "$(SolutionDir)" "$(Configuration)-$(Platform)" "$(TargetPath)"</PostBuildEvent>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>call "$(SolutionDir)updateversion.bat" "$(SolutionDir)" "$(SolutionPath)"</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.6\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.6\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.6\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.6\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.6\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.6\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.6\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.6\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
</Target>
-->
</Project>
6 changes: 5 additions & 1 deletion CAcertInstall/CertificateStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

namespace CAcertInstall
{
public class CertificateStore
public static class CertificateStore
{
public static bool IsCertificateInstalled(Certificate certificate)
{
Debug.Assert(certificate != null);

bool Found = false;

X509Store store = new X509Store(certificate.StoreName, StoreLocation.CurrentUser);
Expand Down Expand Up @@ -44,6 +46,8 @@ public static bool InstallCertificates(Certificate[] certificates)

public static bool InstallCertificate(Certificate certificate)
{
Debug.Assert(certificate != null);

X509Store store = new X509Store(certificate.StoreName, StoreLocation.LocalMachine);
bool Result;

Expand Down
3 changes: 3 additions & 0 deletions CAcertInstall/Converters/BooleanToVisibilityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class BooleanToVisibilityConverter: IValueConverter
{
public object Convert(object value, Type target_type, object parameter, CultureInfo culture)
{
if (parameter == null)
throw new ArgumentNullException(nameof(parameter));

bool BooleanValue = (bool)value;
CompositeCollection VisibilityList = parameter as CompositeCollection;
return BooleanValue ? VisibilityList[0] : VisibilityList[1];
Expand Down
22 changes: 9 additions & 13 deletions CAcertInstall/Localization/LocalizedString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,25 @@ namespace Localization
public class LocalizedString: DependencyObject, INotifyPropertyChanged
{
#region Init
static LocalizedString()
public LocalizedString()
{
StringList = new List<LocalizedString>();
StringList.Add(this);
}

private static Language GetCurrentCultureLanguage()
{
switch (CultureInfo.CurrentCulture.LCID)
{
default:
case 0x0409:
_CurrentLanguage = Language.ENU;
break;
return Language.ENU;

case 0x040C:
_CurrentLanguage = Language.FRA;
break;
return Language.FRA;
}
}

public LocalizedString()
{
StringList.Add(this);
}

private static List<LocalizedString> StringList;
private static List<LocalizedString> StringList = new List<LocalizedString>();
#endregion

#region Properties
Expand Down Expand Up @@ -62,7 +58,7 @@ public static Language CurrentLanguage
NotifyLanguageChanged(_CurrentLanguage);
}
}
private static Language _CurrentLanguage;
private static Language _CurrentLanguage = GetCurrentCultureLanguage();

public string Current
{
Expand Down
7 changes: 6 additions & 1 deletion CAcertInstall/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ private void OnYes(object sender, ExecutedRoutedEventArgs e)
{
StatusWindow Dlg = new StatusWindow();

Dlg.Success = CertificateStore.InstallCertificates(new Certificate[] { App.certificateRoot, App.certificateClass3 });
Certificate CertificateRoot = App.CertificateRoot;
Debug.Assert(CertificateRoot != null);
Certificate CertificateClass3 = App.CertificateClass3;
Debug.Assert(CertificateClass3 != null);

Dlg.Success = CertificateStore.InstallCertificates(new Certificate[] { CertificateRoot, CertificateClass3 });
Dlg.ShowDialog();

Close();
Expand Down
5 changes: 3 additions & 2 deletions CAcertInstall/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.6")]
[assembly: AssemblyFileVersion("1.0.0.13")]
[assembly: AssemblyVersion("1.0.0.21")]
[assembly: AssemblyFileVersion("1.0.0.28")]
[assembly: NeutralResourcesLanguage("en-US")]
8 changes: 8 additions & 0 deletions CAcertInstall/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.6" targetFramework="net452" developmentDependency="true" />
<package id="Microsoft.CodeAnalysis.VersionCheckAnalyzer" version="2.9.6" targetFramework="net452" developmentDependency="true" />
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.6" targetFramework="net452" developmentDependency="true" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.6" targetFramework="net452" developmentDependency="true" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.6" targetFramework="net452" developmentDependency="true" />
</packages>

0 comments on commit 1bc1ef5

Please sign in to comment.