构建父项目

时间:2018-01-29 07:43:40

标签: .net msbuild

我有2个项目,一个(.Net 4.7)ASP.Net Web API项目和一个类库。

Web API引用类库。

类库在csproj中具有以下AfterBuild目标:

<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">
    <Delete Files="$(TargetDir)\Resources\config.json" />
    <Copy SourceFiles="$(ProjectDir)\Resources\config.release.json" DestinationFiles="$(TargetDir)\Resources\config.json" />
  </Target>

在调试和发布配置中构建类lib时,这可以很好地工作,要么保留配置,要么分别用发布配置替换它。

不幸的是,当我构建Web API项目时,这似乎不起作用。无论我使用哪个配置,它都不会在构建类库时触发AfterBuild。

是否有诀窍,或者我错过了这项工作,或者它是否按预期工作?

编辑:来自csproj的Web Api Projectreference:

  <ItemGroup>
    <ProjectReference Include="..\ImportLibNet\ImportLibNet.csproj">
      <Project>{5e8d50d2-ce70-4afa-95ed-e182515226a1}</Project>
      <Name>ImportLibNet</Name>
    </ProjectReference>
  </ItemGroup>

0 个答案:

没有答案