包括在BeforeBuild中生成的文件到编译列表

时间:2013-02-04 07:26:48

标签: visual-studio-2010 msbuild

以下是我的MSBuild XML。在BeforeBuild中生成的文件不包含在DLL中。我期待包含该文件。我注意到在BuildBuild中调用了CoreBuild。如何重新进行重建,包括生成的文件。

由于

克里斯

<?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>

2 个答案:

答案 0 :(得分: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. 构建期间采取的步骤是     一个。 BeforeBuild     湾构建(包括CoreBuild)     C。 AfterBuild
  2. 由于我们需要在MyProject.DLL中构建MyDatabase.Views.cs,我们必须在到达Build(b)之前生成它......所以我们将它放在BeforeBuild(a)中
  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”并且它有效。
  7. 它进行了重建,项目DLL生成了我生成的视图。

答案 1 :(得分:0)

直接在csharp目标行之后

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

添加此

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

VS将再次获取源代码进行编译,而不是在构建过程开始时使用缓存版本。

相关问题