2013-02-04 47 views
0

以下是我的MSBuild XML。在BeforeBuild中生成的文件不包含在DLL中。我期待的文件包括在內。我注意到CoreBuild在BeforeBuild中被調用。如何重新生成包括生成的文件。將BeforeBuild中生成的文件包含到編譯列表中

感謝

克里斯

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> 
    <PropertyGroup> 
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 
    ... 
    <FileAlignment>512</FileAlignment> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 
    <DebugSymbols>true</DebugSymbols> 
    ... 
    <WarningLevel>4</WarningLevel> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 
    <DebugType>pdbonly</DebugType> 
    ... 
    <WarningLevel>4</WarningLevel> 
    </PropertyGroup> 
    <ItemGroup> 
    <Reference Include=".\Resources\Assembly\*.dll" Condition="Exists('.\Resources\Assembly')" /> 
    ... 
    <Reference Include="System.Xml.Linq" /> 
    </ItemGroup> 
    <ItemGroup> 
    <Compile Include=".\**\*.cs" /> 
    </ItemGroup> 
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 
    <UsingTask TaskName="EdmTasks.ViewRefreshTask" AssemblyFile=".\Resources\Assembly\EdmTasks.dll" /> 
    <Target Name="BeforeBuild"> 
    <MsBuild Projects="ForwardPAS.csproj" Targets="CoreBuild" /> 
    <ViewRefreshTask Assembly="$(TargetPath)" Lang="cs" DbContext="FranklinIndexedAnnuityDb" /> 
    </Target> 
</Project> 
+0

1.您將生成的程序集包含在將由CoreBuild構建的程序集中。 2.我們應該說CoreBuild依賴於BeforeBuild,這樣MSBuild將不會並行地執行它們。 – Soundararajan

+0

我的任務ViewRefreshTask需要CoreBuild發生......因爲它使用DLL。然後它生成一個CS文件。我想要發生的是,生成的CS文件是否包含在項目中......因此,在BeforeBuild結束並且Build來了之後,現在將生成的文件構建到DLL中。 –

+0

我添加了一個Task來運行MsBuild(Target:CoreBuild)到BeforeBuild進行重建...這裏有詳細信息 –

回答

0
<Target Name="BeforeBuild"> 
    <MsBuild Projects="MyProject.csproj" Targets="CoreBuild" /> 
    <ViewRefreshTask Assembly="$(TargetPath)" Lang="cs" DbContext="MyDatabaseContext" /> 
    <MsBuild Projects="MyProject.csproj" Targets="CoreBuild" Properties="Rerun=true" /> 
</Target> 
  1. 在構建過程中所採取的措施是 一個。在構建之前 b。構建(包括CoreBuild) c。 AfterBuild
  2. 由於我們需要MyDatabase.Views.cs要建在MyProject.DLL,我們不得不產生之前,我們到達構建(B)......所以我們把它放在BeforeBuild(一)
  3. 但ViewRefreskTask(即生成此文件)需要MyProject.DLL作爲輸入...所以在ViewRefreskTask之前,我們稱之爲「CoreBuild」(構建MyProject.dll)
  4. 我最初假設當BeforeBuild完成時,它將繼續生成並重建項目(因爲有一個新文件是Compile ItemGroup)...但它沒有......它只是給了一個消息「Target」CoreBuild「跳過了。 「
  5. 因此,我添加了一個新的任務...這仍然給我」目標「CoreBuild」跳過。先前建成功。「
  6. 最後,感謝http://social.msdn.microsoft.com/forums/en-US/msbuild/thread/8db6b9e4-16dd-48b2-b243-c6e4c9670982/我添加了Properties =」Rerun = true「,它工作。

它做了重建和項目DLL有我的生成視圖。

+0

您能否將此標記爲已回答。 – Soundararajan

0

後直接csharp的目標相一致

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 

添加此

<PropertyGroup> 
    <UseHostCompilerIfAvailable>False</UseHostCompilerIfAvailable> 
</PropertyGroup> 

VS將再次搶源代碼編譯,而不是使用在構建過程開始緩存版本。

相關問題