への最小限の条件付き調整.csproj
で、msbuild プロジェクトを作成してポータブル ライブラリ ソリューションをコンパイルし、追加の .net 4.0 プロファイル バイナリを生成できます。
Build.proj:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectToBuild Include="MyPortableSolution.sln">
<Properties>Configuration=Release;</Properties>
</ProjectToBuild>
<ProjectToBuild Include="MyPortableSolution.sln">
<Properties>Configuration=Release;OutputPath=bin\Release.net40\;IntermediateOutputPath=obj\Release.net40\;UseNet40=true;</Properties>
</ProjectToBuild>
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="@(ProjectToBuild)"/>
</Target>
</Project>
MyPortableProj.csproj の 2 つの領域を変更します。
最初の置換:
<TargetFrameworkProfile>Profile46</TargetFrameworkProfile>
と:
<UseNet40 Condition=" '$(UseNet40)' == '' ">false</UseNet40>
<TargetFrameworkProfile Condition="$(UseNet40) == false">Profile46</TargetFrameworkProfile>
2 番目の置換:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
と:
<Import Condition="$(UseNet40) == true" Project="$(SolutionDir)\refs.targets" />
<Import Condition="$(UseNet40) == true" Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Condition="$(UseNet40) == false" Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
含むrefs.targets
これは、必要なアセンブリ参照を含むファイルです(プロジェクトからプロジェクトへの編集) :
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
</Project>
注: Visual Studio が別の方法で解析して表示するため、別のファイルを使用します。
msbuild Build.proj
これにより、ポータブル ライブラリが作成されbin\Release
、.net 40 固有のライブラリが作成されます。bin\Release.net40