Conditionally include assemblies depending on Platform setting with MSBuild

We can conditinallly include assemblies depending on Platform setting by modifying project file.

 

To open your project file, you can right-click project node, and choose Unload Project, and then right-click project node again, and choose Edit MyProj.csproj. And you also can open it in project directory.

 

After opening it, You will see <Reference> and <ProjectReference> items, <Refenerece> item is to include the assembly which is registerd in GAC. <ProjectReference> item is to include the project reference to this project. So you can add condition property in these two items, so that you can include corresponding assembies according to Platform setting. For example:

  <Reference Include="System.Xml" Condition=" '$(Platform)' == 'x86'" />  

  <ProjectReference Include="../ClassLibrary/ClassLibrary.csproj" Condition="'$(Platform)' == 'x64'">
   <Project>{89798266-B6B9-4E3F-8368-562077F19205}</Project>
   <Name>ClassLibrary1</Name>
  </ProjectReference>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值