-using System;\r
-using System.IO;\r
-\r
-namespace NaGet\r
-{\r
- /// <summary>\r
- /// 環境変数などを取り扱うクラス\r
- /// </summary>\r
- public sealed class Env\r
- {\r
- /// <summary>\r
- /// 呼び出し禁止\r
- /// </summary>\r
- private Env()\r
- {\r
- }\r
-\r
- \r
- /// <summary> \r
- /// ファイルリスト提供サーバのリストファイル \r
- /// </summary>\r
- public static readonly string ProviderListFile = "provider.list.txt";\r
-\r
- /// <summary>\r
- /// ファイルリストから読み込まれたパッケージのリストファイル\r
- /// </summary>\r
- public static readonly string PackageListFile = "packages.list.xml";\r
-\r
- /// <summary>\r
- /// 本ソフトウェアを介してインストールされたパッケージのリストファイル\r
- /// </summary>\r
- public static readonly string ArchiveInstalledPackageListFile = "packages.envinstalled.xml";\r
-\r
- /// <summary>\r
- /// システムから検出されたパッケージのリストファイル\r
- /// </summary>\r
- public static readonly string SystemInstalledPackageListFile = "packages.sysinstalled.xml";\r
- \r
- /// <summary>\r
- /// インストールログファイル\r
- /// </summary>\r
- public static readonly string SystemInstalledPackageLogFile = "packages.sysinstalled.log.xml";\r
- \r
- private static string appDataFolderPath = null;\r
- \r
- /// <summary>\r
- /// アプリケーションデータを保存するフォルダのパス\r
- /// </summary>\r
- public static string AppDataFolderPath\r
- {\r
- get {\r
- if (appDataFolderPath == null) {\r
-// string progFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);\r
-// if (Path.GetDirectoryName(Environment.CurrentDirectory) == progFiles) {\r
-// string appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);\r
-// return Path.Combine(appData, "AppliStation");\r
-// } else {\r
- return Environment.CurrentDirectory;\r
-// }\r
- } else {\r
- return appDataFolderPath;\r
- }\r
- }\r
- set { appDataFolderPath = value; }\r
- }\r
-\r
- /// <summary>\r
- /// インストーラの一時置き場の親ディレクトリ\r
- /// </summary>\r
- public static string ArchiveFolderPath\r
- {\r
- get { return Path.Combine(AppDataFolderPath, "Cache"); }\r
- }\r
- \r
- /// <summary>\r
- /// アーカイバ方式のパッケージのインストール先フォルダ\r
- /// </summary>\r
- public static string ArchiveProgramFiles {\r
- get {\r
- return Path.Combine(AppDataFolderPath, "progs");\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// アーカイバ方式のパッケージのプログラムグループフォルダ\r
- /// </summary>\r
- public static string ArchiveProgramGroup {\r
- get {\r
- return Path.Combine(AppDataFolderPath, "programs");\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// アーカイバ方式のパッケージのSystem32のフォルダ\r
- /// </summary>\r
- public static string ArchiveSystem32 {\r
- get {\r
- return Path.Combine(ArchiveProgramFiles, ".system32");\r
- }\r
- }\r
- }\r
-}\r
+using System;
+using System.IO;
+using System.Net;
+
+namespace NaGet
+{
+ /// <summary>
+ /// 環境変数などを取り扱うクラス
+ /// </summary>
+ public sealed class Env
+ {
+ /// <summary>
+ /// 呼び出し禁止
+ /// </summary>
+ private Env()
+ {
+ }
+
+ #region pref.xml関連
+
+ /// <summary>
+ /// 設定を格納
+ /// </summary>
+ private static NaGetLibPref pref;
+
+ /// <summary>
+ /// 設定ファイルを読み込む。一回のみ呼ばれる。
+ /// </summary>
+ private static void loadPref()
+ {
+ string path = Path.Combine(Environment.CurrentDirectory, "pref.xml");
+ try {
+ if (! File.Exists(path)) throw new FileNotFoundException(string.Empty, path);
+ pref = NaGet.Utils.GetDeserializedObject<NaGetLibPref>(path);
+ } catch(Exception) {
+ pref = new NaGetLibPref();
+ }
+ }
+
+ #endregion
+
+ #region ファイルパス
+
+ /// <summary>
+ /// ファイルリスト提供サーバのリストファイル
+ /// </summary>
+ public static readonly string ProviderListFile = "provider.list.txt";
+
+ /// <summary>
+ /// ファイルリストから読み込まれたパッケージのリストファイル
+ /// </summary>
+ public static readonly string PackageListFile = "packages.list.xml";
+
+ /// <summary>
+ /// 本ソフトウェアを介してインストールされたパッケージのリストファイル
+ /// </summary>
+ public static readonly string ArchiveInstalledPackageListFile = "packages.envinstalled.xml";
+
+ /// <summary>
+ /// システムから検出されたパッケージのリストファイル
+ /// </summary>
+ public static readonly string SystemInstalledPackageListFile = "packages.sysinstalled.xml";
+
+ /// <summary>
+ /// インストールログファイル
+ /// </summary>
+ public static readonly string SystemInstalledPackageLogFile = "packages.sysinstalled.log.xml";
+
+ /// <summary>
+ /// アプリケーションデータを保存するフォルダのパス
+ /// </summary>
+ public static string AppDataFolderPath
+ {
+ get {
+ if (pref == null) loadPref();
+
+ if (! string.IsNullOrEmpty(pref.AppDataFolder)) {
+ return pref.AppDataFolder;
+ }
+
+ return Environment.CurrentDirectory;
+ }
+ }
+
+ /// <summary>
+ /// インストーラの一時置き場の親ディレクトリ
+ /// </summary>
+ public static string ArchiveFolderPath
+ {
+ get { return Path.Combine(AppDataFolderPath, "Cache"); }
+ }
+
+ /// <summary>
+ /// アーカイバ方式のパッケージのインストール先フォルダ
+ /// </summary>
+ public static string ArchiveProgramFiles {
+ get {
+ return Path.Combine(AppDataFolderPath, "progs");
+ }
+ }
+
+ /// <summary>
+ /// アーカイバ方式のパッケージのプログラムグループフォルダ
+ /// </summary>
+ public static string ArchiveProgramGroup {
+ get {
+ return Path.Combine(AppDataFolderPath, "programs");
+ }
+ }
+
+ /// <summary>
+ /// アーカイバ方式のパッケージのSystem32のフォルダ
+ /// </summary>
+ public static string ArchiveSystem32 {
+ get {
+ return Path.Combine(ArchiveProgramFiles, ".system32");
+ }
+ }
+
+ #endregion
+
+ #region ネットワーク
+
+ /// <summary>
+ /// ウェブアクセスのためのプロキシを取得する。
+ /// </summary>
+ /// <returns>プロキシ</returns>
+ public static IWebProxy WebProxy
+ {
+ get {
+ if (pref == null) loadPref();
+
+ if (string.IsNullOrEmpty(pref.ProxyAddress)) {
+ // 設定されていないときはシステムのデフォルトを使う
+ return WebRequest.GetSystemWebProxy();
+ } else if (pref.ProxyAddress == "-") {
+ // "-"のとき直接接続
+ return null;
+ } else {
+ // host:portが設定されているならば、それをもとに設定
+ return new WebProxy(pref.ProxyAddress);
+ }
+ }
+ }
+
+ #endregion
+ }
+}
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <PropertyGroup>\r
- <ProjectGuid>{058E953D-3986-4F74-8516-5A50D267D36A}</ProjectGuid>\r
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <OutputType>Library</OutputType>\r
- <RootNamespace>na_get_lib</RootNamespace>\r
- <AssemblyName>na-get-lib</AssemblyName>\r
- <BaseIntermediateOutputPath>bin/</BaseIntermediateOutputPath>\r
- <AllowUnsafeBlocks>False</AllowUnsafeBlocks>\r
- <NoStdLib>False</NoStdLib>\r
- <WarningLevel>4</WarningLevel>\r
- <TreatWarningsAsErrors>false</TreatWarningsAsErrors>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
- <OutputPath>bin\Debug\</OutputPath>\r
- <DebugSymbols>true</DebugSymbols>\r
- <DebugType>Full</DebugType>\r
- <Optimize>true</Optimize>\r
- <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>\r
- <DefineConstants>DEBUG;TRACE</DefineConstants>\r
- <OutputType>Library</OutputType>\r
- <AssemblyName>na-get-lib</AssemblyName>\r
- <RootNamespace>na_get_lib</RootNamespace>\r
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">\r
- <OutputPath>bin\Release\</OutputPath>\r
- <DebugSymbols>false</DebugSymbols>\r
- <DebugType>None</DebugType>\r
- <Optimize>true</Optimize>\r
- <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>\r
- <DefineConstants>TRACE</DefineConstants>\r
- <OutputType>Library</OutputType>\r
- <AssemblyName>na-get-lib</AssemblyName>\r
- <RootNamespace>na_get_lib</RootNamespace>\r
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">\r
- <RegisterForComInterop>False</RegisterForComInterop>\r
- <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>\r
- <BaseAddress>4194304</BaseAddress>\r
- <PlatformTarget>AnyCPU</PlatformTarget>\r
- <FileAlignment>4096</FileAlignment>\r
- </PropertyGroup>\r
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />\r
- <ItemGroup>\r
- <Reference Include="System" />\r
- <Reference Include="System.Xml" />\r
- </ItemGroup>\r
- <ItemGroup>\r
- <Compile Include="AssemblyInfo.cs" />\r
- <Compile Include="NaGet.InteropServices\ComDirectAccess.cs" />\r
- <Compile Include="NaGet.InteropServices\CommonArchiverExtracter.cs" />\r
- <Compile Include="NaGet.InteropServices\CreateProcessCaller.cs" />\r
- <Compile Include="NaGet.InteropServices\DllAccess.cs" />\r
- <Compile Include="NaGet.InteropServices\PEFileInfoUtils.cs" />\r
- <Compile Include="NaGet.InteropServices\ShellLink.cs" />\r
- <Compile Include="NaGet.Net\DownloadScanner.cs" />\r
- <Compile Include="NaGet.Net\GuidEnumeratorForCategories.cs" />\r
- <Compile Include="NaGet.Packages.Install\DependeciesResolver.cs" />\r
- <Compile Include="NaGet.Packages.Install\InstallationLog.cs" />\r
- <Compile Include="NaGet.Packages\PackageListsManager.cs" />\r
- <Compile Include="NaGet.Packages\VersionComparetor.cs" />\r
- <Compile Include="NaGet.SubCommands\NaGetInstall.cs" />\r
- <Compile Include="NaGet.SubCommands\NaGetTask.cs" />\r
- <Compile Include="NaGet.SubCommands\NaGetTaskSet.cs" />\r
- <Compile Include="NaGet.SubCommands\NaGetUninstall.cs" />\r
- <Compile Include="NaGet\ArgParser.cs" />\r
- <Compile Include="NaGet\Env.cs" />\r
- <Compile Include="NaGet\Utils.cs" />\r
- <Compile Include="NaGet.Net\Downloader.cs" />\r
- <Compile Include="NaGet.Packages\HashValue.cs" />\r
- <Compile Include="NaGet.Packages\Package.cs" />\r
- <Compile Include="NaGet.Packages\Platform.cs" />\r
- <Compile Include="NaGet.Packages\PackageList.cs" />\r
- <Compile Include="NaGet.Packages\ProviderList.cs" />\r
- <Compile Include="NaGet.Packages.Install\Installation.cs" />\r
- <Compile Include="NaGet.Packages.Install\RegistriedUninstallers.cs" />\r
- <Compile Include="NaGet.Packages.Install\Uninstallation.cs" />\r
- <Compile Include="NaGet.Packages.Install\UninstallInformation.cs" />\r
- <Compile Include="NaGet.Packages.Install\InstalledPackage.cs" />\r
- <Compile Include="NaGet.SubCommands\NaGetUpdate.cs" />\r
- </ItemGroup>\r
- <ItemGroup>\r
- <Folder Include="NaGet.InteropServices" />\r
- <Folder Include="NaGet.SubCommands" />\r
- </ItemGroup>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectGuid>{058E953D-3986-4F74-8516-5A50D267D36A}</ProjectGuid>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <OutputType>Library</OutputType>
+ <RootNamespace>na_get_lib</RootNamespace>
+ <AssemblyName>na-get-lib</AssemblyName>
+ <BaseIntermediateOutputPath>bin/</BaseIntermediateOutputPath>
+ <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
+ <NoStdLib>False</NoStdLib>
+ <WarningLevel>4</WarningLevel>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+ <OutputPath>bin\Debug\</OutputPath>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>Full</DebugType>
+ <Optimize>true</Optimize>
+ <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <OutputType>Library</OutputType>
+ <AssemblyName>na-get-lib</AssemblyName>
+ <RootNamespace>na_get_lib</RootNamespace>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+ <OutputPath>bin\Release\</OutputPath>
+ <DebugSymbols>false</DebugSymbols>
+ <DebugType>None</DebugType>
+ <Optimize>true</Optimize>
+ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+ <DefineConstants>TRACE</DefineConstants>
+ <OutputType>Library</OutputType>
+ <AssemblyName>na-get-lib</AssemblyName>
+ <RootNamespace>na_get_lib</RootNamespace>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+ <BaseAddress>4194304</BaseAddress>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <FileAlignment>4096</FileAlignment>
+ </PropertyGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyInfo.cs" />
+ <Compile Include="NaGet.InteropServices\ComDirectAccess.cs" />
+ <Compile Include="NaGet.InteropServices\CommonArchiverExtracter.cs" />
+ <Compile Include="NaGet.InteropServices\CreateProcessCaller.cs" />
+ <Compile Include="NaGet.InteropServices\DllAccess.cs" />
+ <Compile Include="NaGet.InteropServices\PEFileInfoUtils.cs" />
+ <Compile Include="NaGet.InteropServices\ShellLink.cs" />
+ <Compile Include="NaGet.Net\DownloadScanner.cs" />
+ <Compile Include="NaGet.Net\GuidEnumeratorForCategories.cs" />
+ <Compile Include="NaGet.Packages.Install\DependeciesResolver.cs" />
+ <Compile Include="NaGet.Packages.Install\InstallationLog.cs" />
+ <Compile Include="NaGet.Packages\PackageListsManager.cs" />
+ <Compile Include="NaGet.Packages\VersionComparetor.cs" />
+ <Compile Include="NaGet.SubCommands\NaGetInstall.cs" />
+ <Compile Include="NaGet.SubCommands\NaGetTask.cs" />
+ <Compile Include="NaGet.SubCommands\NaGetTaskSet.cs" />
+ <Compile Include="NaGet.SubCommands\NaGetUninstall.cs" />
+ <Compile Include="NaGet\ArgParser.cs" />
+ <Compile Include="NaGet\Env.cs" />
+ <Compile Include="NaGet\NaGetLibPref.cs" />
+ <Compile Include="NaGet\Utils.cs" />
+ <Compile Include="NaGet.Net\Downloader.cs" />
+ <Compile Include="NaGet.Packages\HashValue.cs" />
+ <Compile Include="NaGet.Packages\Package.cs" />
+ <Compile Include="NaGet.Packages\Platform.cs" />
+ <Compile Include="NaGet.Packages\PackageList.cs" />
+ <Compile Include="NaGet.Packages\ProviderList.cs" />
+ <Compile Include="NaGet.Packages.Install\Installation.cs" />
+ <Compile Include="NaGet.Packages.Install\RegistriedUninstallers.cs" />
+ <Compile Include="NaGet.Packages.Install\Uninstallation.cs" />
+ <Compile Include="NaGet.Packages.Install\UninstallInformation.cs" />
+ <Compile Include="NaGet.Packages.Install\InstalledPackage.cs" />
+ <Compile Include="NaGet.SubCommands\NaGetUpdate.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="NaGet.InteropServices" />
+ <Folder Include="NaGet.SubCommands" />
+ </ItemGroup>
</Project>
\ No newline at end of file