2013-02-04 26 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将再次抢源代码编译,而不是使用在构建过程开始缓存版本。

相关问题