ソリューション内に2つの別々のプロジェクトを含めることが受け入れられない場合は、独自のMSBuildスクリプトの作成を検討することをお勧めします。
これは、ビルド時にカスタムコンパイル定数を定義してから、アプリケーションの2つのバージョン(「フル」と「ライト」)をビルドできるカスタムMSBuildスクリプトの例です。
<Project DefaultTargets="BuildAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildVersionFull>FULL</BuildVersionFull>
<BuildVersionLite>LITE</BuildVersionLite>
</PropertyGroup>
<ItemGroup>
<Projects Include="$(MSBuildProjectDirectory)\MyApp.vbproj" />
</ItemGroup>
<Target Name="BuildAll" DependsOnTargets="BuildFull;BuildLite" />
<Target Name="BuildFull">
<MSBuild Projects="@(Projects)" Properties="DefineConstants=$(BuildVersionFull);OutputPath=binFull\;BaseIntermediateOutputPath=objFull\;AssemblyName=MyApp_Full" />
</Target>
<Target Name="BuildLite">
<MSBuild Projects="@(Projects)" Properties="DefineConstants=$(BuildVersionLite);OutputPath=binLite\;BaseIntermediateOutputPath=objLite\;AssemblyName=MyApp_Lite" />
</Target>
</Project>
あなたがする必要があること:
- 新しいファイルを作成し、アプリケーションのプロジェクトファイルと同じディレクトリに「MyBuild.xml」として保存します。
- アプリケーションのプロジェクトファイルの名前を反映するように変更します。
- Visual Studioコマンドプロンプトを開き、「msbuild」を実行します。
プロジェクト内で、「FULL」および「LITE」条件付きコンパイル定数を使用して、特定のステートメントをコンパイルするかどうかを決定できます。
#If FULL Then
' Compile code for the "Full" version.
#End If