MSBuild not creating bin directory

时间:2015-12-14 18:00:09

标签: msbuild app-config web.config-transform

I'm trying to migrate my build system away from Visual Studio and onto MSBuild directly (to facilitate a switch to an automated CI tool) but I'm having a problem with one of the projects that I'm trying to switch.

The two projects out of the solution that won't build have configuration transforms set up on them, and from what I can gather from the csproj file in both cases, there is a Target TranformOnBuild targets which seems to run before PrepareforBuild. The problem is that the bin folder has not been created at this point.

The section of the app.config that deals with this is:

<Target Name="TransformOnBuild" BeforeTargets="PrepareForBuild">
  <PropertyGroup>
    <outputTypeExtension Condition="'$(OutputType)' == 'exe' or '$(OutputType)' == 'winexe'">exe</outputTypeExtension>
    <outputTypeExtension Condition="'$(OutputType)' == 'Library'">dll</outputTypeExtension>
  </PropertyGroup>
  <TransformXml Condition="'$(AppCfgType)' == 'Web' and Exists('$(ConfigDir)\Web.Base.config') and Exists('$(ConfigDir)\Web.$(Configuration).config')" Source="$(ConfigDir)\Web.Base.config" Transform="$(ConfigDir)\Web.$(Configuration).config" Destination="Web.config" />
  <TransformXml Condition="'$(AppCfgType)' == 'App' and $(InlineAppCfgTransforms) == true and Exists('$(ConfigDir)\App.Base.config') and Exists('$(ConfigDir)\App.$(Configuration).config')" Source="$(ConfigDir)\App.Base.config" Transform="$(ConfigDir)\App.$(Configuration).config" Destination="App.config" />
  <TransformXml Condition="'$(AppCfgType)' == 'App' and $(InlineAppCfgTransforms) != true and Exists('App.config') and Exists('App.$(Configuration).config')" Source="App.config" Transform="App.$(Configuration).config" Destination="$(OutDir)$(AssemblyName).$(outputTypeExtension).config" />
  <Copy Condition="'$(AppCfgType)' == 'Web' and Exists('$(ConfigDir)\Web.Base.config') and !Exists('$(ConfigDir)\Web.$(Configuration).config')" SourceFiles="$(ConfigDir)\Web.Base.config" DestinationFiles="Web.config" />
  <Copy Condition="'$(AppCfgType)' == 'App' and $(InlineAppCfgTransforms) == true and Exists('$(ConfigDir)\App.Base.config') and !Exists('$(ConfigDir)\App.$(Configuration).config')" SourceFiles="$(ConfigDir)\App.Base.config" DestinationFiles="App.config" />
  <Copy Condition="'$(AppCfgType)' == 'App' and $(InlineAppCfgTransforms) != true and Exists('App.config') and !Exists('App.$(Configuration).config')" SourceFiles="App.config" DestinationFiles="$(OutDir)$(AssemblyName).$(outputTypeExtension).config" />
</Target>

I'm not sure what the recommended approach to getting MSBuild to create the necessary directories is, or if it is better to move the transform to a phase after the build has been done?

The build works fine if I create the directories manually, but I'd like to automate this in MS Build to make things easier when I move to a build server.

What would be the recommended way to sort out this problem?

Thanks,

Richard.

0 个答案:

没有答案