この質問に答えてくれたのはハンスの功績だと思いますが、いくつかの実験の後、私は少し自宅に近い解決策を得ました:
Visual Studio 内で CIL/MSIL をコンパイルする方法
次のハックは、次のプロジェクトを取得します。
- Visual Studio でのデバッグとリリースのビルド構成を尊重します。
- 必要に応じて、プロジェクトの設定で設定されたキー ファイルを使用して、結果の CIL アセンブリに署名します。
- ソース管理に追加できます。
次の手順を実行します:
- 空の C# クラス ライブラリを作成する
- ソリューション フォルダーでプロジェクトを右クリックし、[プロジェクトのアンロード] を選択します。
- アンロードされたプロジェクトを右クリックし、「プロジェクトの編集」を選択します
- csprof ファイルで、一番下までスクロールし、"Import ... Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" という行を見つけて、http://pastebin のコードに置き換えます。 com/KEJtyQLu (以下にコピー)
XML は次のとおりです。
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<Target Name="CreateManifestResourceNames" />
<Target Name="CoreCompile" Inputs="$(MSBuildAllProjects);@(Compile);" Outputs="@(IntermediateAssembly);$(NonExistentFile);">
<GetFrameworkPath>
<Output TaskParameter="Path" PropertyName="FrameworkPath" />
</GetFrameworkPath>
<PropertyGroup>
<IlAsmCommand>"$(FrameworkPath)\Ilasm.exe" /NOLOGO /DLL /OUTPUT:"@(IntermediateAssembly)" </IlAsmCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' " >
<IlAsmCommand>$(IlAsmCommand) /DEBUG </IlAsmCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' " ><IlAsmCommand>$(IlAsmCommand) /OPTIMIZE </IlAsmCommand></PropertyGroup>
<PropertyGroup Condition=" '$(AssemblyOriginatorKeyFile)' != '' " >
<IlAsmCommand>$(IlAsmCommand) /KEY:"$(AssemblyOriginatorKeyFile)" </IlAsmCommand>
</PropertyGroup>
<Exec Command="$(IlAsmCommand) @(Compile->'"%(FullPath)"', ' ')"
Outputs="@(IntermediateAssembly)" />
<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''" />
</Target>