Skip to content

Commit

Permalink
Update External file install
Browse files Browse the repository at this point in the history
Been divide visual studio runtime type in x86 and x64.
  • Loading branch information
minfia committed Aug 16, 2021
1 parent 267b796 commit 248b4fd
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 46 deletions.
66 changes: 48 additions & 18 deletions source/AviUtlAutoInstaller/Models/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ namespace AviUtlAutoInstaller.Models
class AppConfig
{
#region 設定キー名
private const string KEY_RUNTIME_VS2008 = "vs2008runtime";
private const string KEY_RUNTIME_VS2013 = "vs2013runtime";
private const string KEY_RUNTIME_VS201X = "vs201Xruntime";
private const string KEY_RUNTIME_VS2008_x86 = "vs2008runtime_x86";
private const string KEY_RUNTIME_VS2008_x64 = "vs2008runtime_x64";
private const string KEY_RUNTIME_VS2013_x86 = "vs2013runtime_x86";
private const string KEY_RUNTIME_VS2013_x64 = "vs2013runtime_x64";
private const string KEY_RUNTIME_VS201X_x86 = "vs201Xruntime_x86";
private const string KEY_RUNTIME_VS201X_x64 = "vs201Xruntime_x64";
#endregion

/// <summary>
Expand All @@ -21,17 +24,29 @@ class AppConfig
public class Runtime
{
/// <summary>
/// VS2008ランタイム
/// VS2008ランタイム(x86)
/// </summary>
public static bool vs2008 = false;
public static bool vs2008_x86 = false;
/// <summary>
/// VS2013ランタイム
/// VS2008ランタイム(x64)
/// </summary>
public static bool vs2013 = false;
public static bool vs2008_x64 = false;
/// <summary>
/// VS201Xランタイム
/// VS2013ランタイム(x86)
/// </summary>
public static bool vs201X = false;
public static bool vs2013_x86 = false;
/// <summary>
/// VS2013ランタイム(x64)
/// </summary>
public static bool vs2013_x64 = false;
/// <summary>
/// VS201Xランタイム(x86)
/// </summary>
public static bool vs201X_x86 = false;
/// <summary>
/// VS201Xランタイム(x64)
/// </summary>
public static bool vs201X_x64 = false;
}

/// <summary>
Expand Down Expand Up @@ -61,17 +76,29 @@ public static void Load()

foreach (string key in appConfig.AllKeys)
{
if (key == KEY_RUNTIME_VS2008)
if (key == KEY_RUNTIME_VS2008_x86)
{
Runtime.vs2008_x86 = Convert.ToBoolean(appConfig[key].Value);
}
if (key == KEY_RUNTIME_VS2008_x64)
{
Runtime.vs2008_x64 = Convert.ToBoolean(appConfig[key].Value);
}
if (key == KEY_RUNTIME_VS2013_x86)
{
Runtime.vs2013_x86 = Convert.ToBoolean(appConfig[key].Value);
}
if (key == KEY_RUNTIME_VS2013_x64)
{
Runtime.vs2008 = Convert.ToBoolean(appConfig[key].Value);
Runtime.vs2013_x64 = Convert.ToBoolean(appConfig[key].Value);
}
if (key == KEY_RUNTIME_VS2013)
if (key == KEY_RUNTIME_VS201X_x86)
{
Runtime.vs2013 = Convert.ToBoolean(appConfig[key].Value);
Runtime.vs201X_x86 = Convert.ToBoolean(appConfig[key].Value);
}
if (key == KEY_RUNTIME_VS201X)
if (key == KEY_RUNTIME_VS201X_x64)
{
Runtime.vs201X = Convert.ToBoolean(appConfig[key].Value);
Runtime.vs201X_x64 = Convert.ToBoolean(appConfig[key].Value);
}
}
}
Expand All @@ -88,9 +115,12 @@ public static void Save()
Configuration saveConfigFile = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
KeyValueConfigurationCollection settings = saveConfigFile.AppSettings.Settings;

Update(settings, KEY_RUNTIME_VS2008, Runtime.vs2008.ToString());
Update(settings, KEY_RUNTIME_VS2013, Runtime.vs2013.ToString());
Update(settings, KEY_RUNTIME_VS201X, Runtime.vs201X.ToString());
Update(settings, KEY_RUNTIME_VS2008_x86, Runtime.vs2008_x86.ToString());
Update(settings, KEY_RUNTIME_VS2008_x64, Runtime.vs2008_x64.ToString());
Update(settings, KEY_RUNTIME_VS2013_x86, Runtime.vs2013_x86.ToString());
Update(settings, KEY_RUNTIME_VS2013_x64, Runtime.vs2013_x64.ToString());
Update(settings, KEY_RUNTIME_VS201X_x86, Runtime.vs201X_x86.ToString());
Update(settings, KEY_RUNTIME_VS201X_x64, Runtime.vs201X_x64.ToString());

saveConfigFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(saveConfigFile.AppSettings.SectionInformation.Name);
Expand Down
105 changes: 77 additions & 28 deletions source/AviUtlAutoInstaller/Models/ItemInstallProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ private enum ExternalFileType
{ "vc2008redist_x64.exe", ExternalFileType.VSRuntime },
{ "vc2013redist_x86.exe", ExternalFileType.VSRuntime },
{ "vc2013redist_x64.exe", ExternalFileType.VSRuntime },
{ "vc201Xredist.x86.exe", ExternalFileType.VSRuntime },
{ "vc201Xredist.x64.exe", ExternalFileType.VSRuntime },
{ "vc201Xredist_x86.exe", ExternalFileType.VSRuntime },
{ "vc201Xredist_x64.exe", ExternalFileType.VSRuntime },
};

/// <summary>
Expand All @@ -154,37 +154,13 @@ public static bool ExternalInstall(string[] externalFiles)
{
case ExternalFileType.VSRuntime:
{
if (exFile.Contains("vc2008") && !AppConfig.Runtime.vs2008)
{
args = "/q";
}
else if (exFile.Contains("vc2013") && !AppConfig.Runtime.vs2013)
{
args = "quiet";
}
else if (exFile.Contains("vc201X") && !AppConfig.Runtime.vs201X)
{
args = "quiet";
}
else
if ((args = GetVSRuntimeArgument(exFile)) == string.Empty)
{
break;
}
if (VSRuntimeInstall(exFilePath, args))
{
if (exFile.Contains("vc2008"))
{
AppConfig.Runtime.vs2008 = true;
}
else if (exFile.Contains("vc2013"))
{
AppConfig.Runtime.vs2013 = true;
}
else if (exFile.Contains("vc201X"))
{
AppConfig.Runtime.vs201X = true;
}
AppConfig.Save();
RegistVSRuntime(exFile);
}
}
break;
Expand All @@ -198,6 +174,37 @@ public static bool ExternalInstall(string[] externalFiles)
return true;
}

/// <summary>
/// VisualStudioのランタイムインストール用の引数を取得
/// </summary>
/// <param name="exFile">インストーラ名</param>
/// <returns>arg or string.Empty</returns>
private static string GetVSRuntimeArgument(string exFile)
{
string args = string.Empty;

if (exFile.Contains("vc2008") &&
(exFile.Contains("_x86") && !AppConfig.Runtime.vs2008_x86) ||
(exFile.Contains("_x64") && !AppConfig.Runtime.vs2008_x64))
{
args = "/q";
}
else if (exFile.Contains("vc2013") &&
(exFile.Contains("_x86") && !AppConfig.Runtime.vs2013_x86) ||
(exFile.Contains("_x64") && !AppConfig.Runtime.vs2013_x64))
{
args = "quiet";
}
else if (exFile.Contains("vc201X") &&
(exFile.Contains("_x86") && !AppConfig.Runtime.vs201X_x86) ||
(exFile.Contains("_x64") && !AppConfig.Runtime.vs201X_x64))
{
args = "quiet";
}

return args;
}

/// <summary>
/// VisualStudioのランタイムインストール
/// </summary>
Expand All @@ -224,6 +231,48 @@ private static bool VSRuntimeInstall(string filePath, string args)
}
}

/// <summary>
/// VisualStudioのランタイムの登録
/// </summary>
/// <param name="exFile">インストーラ名</param>
private static void RegistVSRuntime(string exFile)
{
if (exFile.Contains("vc2008"))
{
if (exFile.Contains("_x86"))
{
AppConfig.Runtime.vs2008_x86 = true;
}
else if (exFile.Contains("_x64"))
{
AppConfig.Runtime.vs2008_x86 = true;
}
}
else if (exFile.Contains("vc2013"))
{
if (exFile.Contains("_x86"))
{
AppConfig.Runtime.vs2013_x86 = true;
}
else if (exFile.Contains("_x64"))
{
AppConfig.Runtime.vs2013_x64 = true;
}
}
else if (exFile.Contains("vc201X"))
{
if (exFile.Contains("_x86"))
{
AppConfig.Runtime.vs201X_x86 = true;
}
else if (exFile.Contains("_x64"))
{
AppConfig.Runtime.vs201X_x64 = true;
}
}
AppConfig.Save();
}

private enum SpecialPluginType
{
PSDToolkit,
Expand Down

0 comments on commit 248b4fd

Please # to comment.