От: | Mr.Delphist | ||
Дата: | 24.10.16 16:19 | ||
Оценка: | 7 (2) |
You should be able to reference different assemblies based on the current build configuration by using either a PowerShell script or using custom MSBuild targets file. Note that using an MSBuild targets file will work cross platform in MonoDevelop and Xamarin Studio where as a PowerShell script will not.
NuGet allows you to include an MSBuild targets file so you can change what happens at build time. In the MSBuild targets file you can have the references and make them conditional based on the current build configuration.
In the build directory of your NuGet package you add an MSBuild .targets file with the same name as your NuGet package id. You can also have different .targets files for a particular target framework (e.g. Net40) by having it under a Net40 subdirectory if you need to.
build\MyPackageId.targets
Then in the MSBuild .targets file you can do something simple such as have the references conditionally added.
<ItemGroup Condition=" '$(Platform)' == 'x86' "> <Reference Include="MyAssembly"> <HintPath>x86\MyAssembly.dll</HintPath> </Reference> </ItemGroup> <ItemGroup Condition=" '$(Platform)' == 'x64' "> <Reference Include="MyAssembly"> <HintPath>x64\MyAssembly.dll</HintPath> </Reference> </ItemGroup>