Skip to content

Commit

Permalink
Moca nuget 統合
Browse files Browse the repository at this point in the history
  • Loading branch information
MiYABiS committed Aug 11, 2017
1 parent e8300bc commit 8a70bd1
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,4 @@ FakesAssemblies/
*.opt
*.bak
*.bak
*.jfm
16 changes: 16 additions & 0 deletions MocaCore.Test/App.Hotfix.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings xdt:Transform="Replace">
<add name="db" connectionString="" providerName="" />
</connectionStrings>
<userSettings>
<MocaCore.Test.My.MySettings xdt:Transform="Replace">
<add key="TestEnvironment" value="true"/>
</MocaCore.Test.My.MySettings>
</userSettings>
<applicationSettings>
<MocaCore.Test.My.MySettings xdt:Transform="Replace">
<add key="TestEnvironment" value="true"/>
</MocaCore.Test.My.MySettings>
</applicationSettings>
</configuration>
16 changes: 16 additions & 0 deletions MocaCore.Test/App.Main.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings xdt:Transform="Replace">
<add name="db" connectionString="" providerName="" />
</connectionStrings>
<userSettings>
<MocaCore.Test.My.MySettings xdt:Transform="Replace">
<add key="TestEnvironment" value="true"/>
</MocaCore.Test.My.MySettings>
</userSettings>
<applicationSettings>
<MocaCore.Test.My.MySettings xdt:Transform="Replace">
<add key="TestEnvironment" value="true"/>
</MocaCore.Test.My.MySettings>
</applicationSettings>
</configuration>
16 changes: 16 additions & 0 deletions MocaCore.Test/App.Release.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings xdt:Transform="Replace">
<add name="db" connectionString="" providerName="" />
</connectionStrings>
<userSettings>
<MocaCore.Test.My.MySettings xdt:Transform="Replace">
<add key="TestEnvironment" value="true"/>
</MocaCore.Test.My.MySettings>
</userSettings>
<applicationSettings>
<MocaCore.Test.My.MySettings xdt:Transform="Replace">
<add key="TestEnvironment" value="true"/>
</MocaCore.Test.My.MySettings>
</applicationSettings>
</configuration>
35 changes: 34 additions & 1 deletion MocaCore.Test/MocaCore.Test.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -48,6 +50,10 @@
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
Expand Down Expand Up @@ -91,6 +97,7 @@
<Compile Include="MocaTestBase.vb" />
<Compile Include="Models\TestRow.vb" />
<Compile Include="Models\UserRow.vb" />
<Compile Include="My Project\AppConfigTransformAssemblyInfo.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -119,6 +126,25 @@
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="App.Hotfix.config">
<DependentUpon>app.config</DependentUpon>
</None>
<None Include="App.Main.config">
<DependentUpon>app.config</DependentUpon>
</None>
<None Include="App.Release.config">
<DependentUpon>app.config</DependentUpon>
</None>
<None Include="log4net.config" />
<None Include="log4net.Hotfix.config">
<DependentUpon>log4net.config</DependentUpon>
</None>
<None Include="log4net.Main.config">
<DependentUpon>log4net.config</DependentUpon>
</None>
<None Include="log4net.Release.config">
<DependentUpon>log4net.config</DependentUpon>
</None>
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
Expand All @@ -128,14 +154,14 @@
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MocaCore\MocaCore20.vbproj">
<Project>{0ffb9cef-465e-4ae8-99d9-5d0eec1e639a}</Project>
<Name>MocaCore20</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand All @@ -161,6 +187,13 @@
<PropertyGroup>
<SsdtUnitTestVersion>2.0</SsdtUnitTestVersion>
</PropertyGroup>
<Import Project="..\packages\MiYABiS.AppConfigTransform.1.0.6\build\MiYABiS.AppConfigTransform.targets" Condition="Exists('..\packages\MiYABiS.AppConfigTransform.1.0.6\build\MiYABiS.AppConfigTransform.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>このプロジェクトは、このコンピューター上にない NuGet パッケージを参照しています。それらのパッケージをダウンロードするには、[NuGet パッケージの復元] を使用します。詳細については、http://go.microsoft.com/fwlink/?LinkID=322105 を参照してください。見つからないファイルは {0} です。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MiYABiS.AppConfigTransform.1.0.6\build\MiYABiS.AppConfigTransform.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MiYABiS.AppConfigTransform.1.0.6\build\MiYABiS.AppConfigTransform.targets'))" />
</Target>
<!-- 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">
Expand Down
12 changes: 12 additions & 0 deletions MocaCore.Test/My Project/AppConfigTransformAssemblyInfo.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

' プログラム要素が CLS (Common Language Specification) に準拠しているかどうかを示します
<Assembly: System.CLSCompliant(True)>

' The Apache Software Foundation log4net Logging Framework
' When you use , please install the log4net from nuget.
' log4net.config を log4net の設定ファイルとする
<Assembly: log4net.Config.XmlConfigurator(ConfigFile:="log4net.config", Watch:=True)>

' App.config Section Protection setting
' When you use , please install the Moca.NETConfiguration from nuget.
'<Assembly: Moca.Configuration.SectionProtection(Moca.Configuration.ProtectionProviderType.DPAPI, "Section Name")>
17 changes: 6 additions & 11 deletions MocaCore.Test/app.config
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="SqlUnitTesting" type="Microsoft.Data.Tools.Schema.Sql.UnitTesting.Configuration.SqlUnitTestingSection, Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<SqlUnitTesting>
<DatabaseDeployment DatabaseProjectFileName="..\..\..\MocaCore.TestMSSQL\MocaCore.TestMSSQL.sqlproj"
Configuration="Debug" />
<DatabaseDeployment DatabaseProjectFileName="..\..\..\MocaCore.TestMSSQL\MocaCore.TestMSSQL.sqlproj" Configuration="Debug" />
<DataGeneration ClearDatabase="true" />
<ExecutionContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\Projects;Initial Catalog=MocaTest;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True"
CommandTimeout="30" />
<PrivilegedContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\Projects;Initial Catalog=MocaTest;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True"
CommandTimeout="30" />
<ExecutionContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\Projects;Initial Catalog=MocaTest;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True" CommandTimeout="30" />
<PrivilegedContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\Projects;Initial Catalog=MocaTest;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True" CommandTimeout="30" />
</SqlUnitTesting>
<connectionStrings>
<add name="MocaCore.Test.My.MySettings.MSSQL" connectionString="Data Source=(localdb)\Projects;Initial Catalog=MocaTest;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MocaCore.Test.My.MySettings.Test" connectionString="Data Source=(localdb)\ProjectsV13;Initial Catalog=MocaTest;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MocaCore.Test.My.MySettings.MSSQL" connectionString="Data Source=(localdb)\Projects;Initial Catalog=MocaTest;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="MocaCore.Test.My.MySettings.Test" connectionString="Data Source=(localdb)\ProjectsV13;Initial Catalog=MocaTest;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.diagnostics>
<sources>
Expand Down
22 changes: 22 additions & 0 deletions MocaCore.Test/log4net.Hotfix.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>

<!-- コンソール出力用 (VS.NET 上 [出力] ウインドウへ) -->
<appender name="DebugAppender" type="log4net.Appender.DebugAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="@%-5level&gt;&gt; [%class.%method.%line] %message%newline"/>
</layout>
</appender>

<!--
Fatal システム停止するような致命的な障害
Error システム停止はしないが、問題となる障害
Warn 障害ではない注意警告
Info 操作ログなどの情報
Debug 開発用のデバッグメッセージ
-->
<root>
<level value="ALL" />
<appender-ref ref="DebugAppender" />
</root>
</log4net>
22 changes: 22 additions & 0 deletions MocaCore.Test/log4net.Main.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>

<!-- コンソール出力用 (VS.NET 上 [出力] ウインドウへ) -->
<appender name="DebugAppender" type="log4net.Appender.DebugAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="@%-5level&gt;&gt; [%class.%method.%line] %message%newline"/>
</layout>
</appender>

<!--
Fatal システム停止するような致命的な障害
Error システム停止はしないが、問題となる障害
Warn 障害ではない注意警告
Info 操作ログなどの情報
Debug 開発用のデバッグメッセージ
-->
<root>
<level value="ALL" />
<appender-ref ref="DebugAppender" />
</root>
</log4net>
140 changes: 140 additions & 0 deletions MocaCore.Test/log4net.Release.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

<appender xdt:Transform="RemoveAll" />
<root xdt:Transform="RemoveAll" />

<!-- ログファイル出力用(日付またはファイルのサイズ制約に基づいた多数のログを生成) -->
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"
xdt:Transform="Insert">
<!--ログファイル名の先頭部分-->
<param name="File" value="logs/log" />
<!-- 追加書き込み -->
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="30" />
<param name="MaximumFileSize" value="10MB" />
<!-- 日付ごとにファイルを作成することを指定 -->
<param name="RollingStyle" value="date" />
<!-- ログ・ファイル名が固定ではないので“false”を指定 -->
<param name="StaticLogFileName" value="false" />
<!-- ファイル名の日付部分 -->
<param name="DatePattern" value='"_"yyyyMMdd".log"' />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] [%-5p] [%C:%4L] - %m%n "/>
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="INFO" />
<levelMax value="FATAL" />
</filter>
</appender>

<!-- SQL Server 出力用 -->
<appender name="ADONetAppender_SqlServer" type="log4net.Appender.AdoNetAppender"
xdt:Transform="Insert">
<!-- DDL
CREATE TABLE [tblLog4net](
[UserName] [varchar](100) NULL,
[Date] [datetime] NULL,
[Thread] [varchar](255) NULL,
[Level] [varchar](50) NULL,
[Class] [varchar](512) NULL,
[Method] [varchar](512) NULL,
[Message] [nvarchar](max) NULL,
[Exception] [nvarchar](max) NULL
) ON [PRIMARY]
-->
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<!-- 接続文字列 -->
<connectionString value="Data Source=.\SQLEXPRESS;Initial Catalog=AppDemo;Integrated Security=True" />
<!-- INSERT文を指定 -->
<commandText value="INSERT INTO tblLog4net ([UserName],[Date],[Thread],[Level],[Class],[Method],[Message],[Exception]) VALUES (@username,@log_date, @thread, @log_level, @class, @method, @message, @exception)" />

<!-- カラム情報 -->
<parameter>
<!-- INSERT文に含まれるパラメータ -->
<parameterName value="@username" />
<dbType value="String" />
<size value="100" />
<layout type="log4net.Layout.PatternLayout">
<!-- パターンを指定 -->
<conversionPattern value="%username" />
</layout>
</parameter>

<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>

<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%t" />
</layout>
</parameter>

<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>

<parameter>
<parameterName value="@class" />
<dbType value="String" />
<size value="512" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%class" />
</layout>
</parameter>

<parameter>
<parameterName value="@method" />
<dbType value="String" />
<size value="512" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%method.%line" />
</layout>
</parameter>

<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="10000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>

<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="10000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%exception" />
</layout>
</parameter>

<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="INFO" />
<levelMax value="FATAL" />
</filter>
</appender>

<root xdt:Transform="Insert">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
<!--
SQL Server へ出力する場合は下記を有効にする
<appender-ref ref="ADONetAppender_SqlServer" />
-->
</root>
</log4net>
27 changes: 27 additions & 0 deletions MocaCore.Test/log4net.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
すべてのファイルを表示し
log4net.Debug.config および log4net.Release.config を編集してください。
ビルド時にソリューション構成によってそれぞれのファイルが出力されます。
-->
<log4net>
<!--
Fatal システム停止するような致命的な障害
Error システム停止はしないが、問題となる障害
Warn 障害ではない注意警告
Info 操作ログなどの情報
Debug 開発用のデバッグメッセージ
-->

<appender name="DebugAppender" type="log4net.Appender.DebugAppender">
<!-- コンソール出力用 (VS.NET 上 [出力] ウインドウへ) -->
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="@%-5level&gt;&gt; [%class.%method.%line] %message%newline"/>
</layout>
</appender>

<root>
<level value="ALL" />
<appender-ref ref="DebugAppender" />
</root>
</log4net>
Loading

0 comments on commit 8a70bd1

Please sign in to comment.