Conditionally include assemblies depending on Platform setting with MSBuild

来源:互联网 发布:vb中tab是什么意思 编辑:程序博客网 时间:2024/06/06 04:37

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>
原创粉丝点击