我有一個csproj文件集合,它們都引用相同的一組源文件,但它們的目標數據略有不同,因此我需要將項目文件分開。例如。有同一個項目的WinPhone,XBox,Desktop,MonoTouch變體。使用Mono和MonoDevelop Mulinogeting C#項目文件
對於真正重複的內容,例如要編譯的.cs文件列表,我想將列表合併到單個文件中,因此我不必確保所有變體都保持同步。我最初嘗試通過從.csprojs中移除源文件並將它們放入由所有csprojs導入的.targets文件來完成此操作,但這樣做會使源文件從VS和MonoDevelop中消失。
我的第二次嘗試是通過使Desktop csproj文件成爲主要文件,並讓所有變體用某些條件邏輯導入csproj。這使得源文件可以從主csproj編輯,並且它們可以構建成所有的風格。現在Visual Studio瞭解我正在嘗試做什麼,但是MonoDevelop無法構建它。在MonoDevelop解決方案中,iOS版本的核心DLL是灰色的,並顯示「(未內置於活動配置)」
我也試過xbuilding csproj和解決方案,它似乎通過了MonoDevelop的問題但打嗝與解決monotouch組件有關的其他事情。我曾經以爲MonoDevelop使用xbuild,但可能不是?
由於這在Windows msbuild中工作,它似乎是單聲道中的錯誤或不支持的功能。或者也許有更好的方法來解決整個場景......我想我會在這裏問。
對於細節, 我Core.iOS.csproj文件看起來像這樣:
<?xml version="1.0" encoding="utf-8"?>
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="Build"
ToolsVersion="4.0" >
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AE37B15F-F4BE-48DE-9F20-F00A601EC89E}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AssemblyName>Core.iOS</AssemblyName>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
</ItemGroup>
<Import Project=".\Core.csproj" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
而且我Core.csproj文件看起來像這樣:
<?xml version="1.0" encoding="utf-8"?>
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="Build"
ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Core</RootNamespace>
</PropertyGroup>
<!-- Using AssemblyName's presence to check for whether this is imported. -->
<PropertyGroup Condition=" '$(AssemblyName)' == '' ">
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{FC495BD8-11B1-46B0-A9DE-F245A0CBEE94}</ProjectGuid>
<AssemblyName>Core</AssemblyName>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<!-- properties similar to Debug -->
</PropertyGroup>
<ItemGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<Import Condition=" '$(AssemblyName)' == 'Core' " Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="[...]" />
<Compile Include="[...]" />
</Project>
而且,就像我說的,一個當使用VS Express for WinPhone和XBox360項目時,這種變化似乎可以正常工作。這是否應該起作用?有一個更好的方法嗎?
感謝,
看起來不錯,Monodevelop在內部使用xbuild。你安裝了哪個版本? – skolima 2012-04-29 06:12:15
感謝您的期待。當我正在研究這個問題來自己回答這個問題時,我的印象是,MonoTouch項目繞過了xbuild並直接調用了mcs,但我可能誤解了它或者正在查看一篇舊文章,但即使這樣,不知道IDE會使用xbuild來決定哪些目標是有效的......我的MonoDevelop版本是2.8.8.4。如果需要重新制作,請告訴我是否有任何我可以提供的幫助。 – 2012-04-29 21:40:19