Christo
Christo

Reputation: 2370

Build All projects in a directory

Im try to build my plugins that sit in a seperate directory on the root.

  <ItemGroup>
    <PluginProjectFiles Include="$(MSBuildStartupDirectory)..\..\Plugins\**\*.csproj"/>
  </ItemGroup>
  <Target Name="BuildPlugins">
    <MSBuild Projects="@(PluginProjectFiles)" Targets="Clean;Build" Properties="Configuration=Release" />
    <Message Text="Dir: $(MSBuildStartupDirectory)" />
  </Target>

Although im having problems. My build runs the 'BuildPlugin' Target but it doesn't build my project files. I really don't want to have to build each project separately if I can avoid it.

Any ideas would be great. Thanks,

Upvotes: 2

Views: 1764

Answers (1)

Christo
Christo

Reputation: 2370

Please refer to my resolution below.

  <PropertyGroup>
    <SrcFolder>$(MSBuildProjectDirectory)\..\..</SrcFolder>
  </PropertyGroup>
  <ItemGroup>
    <PluginProjectsFiles Include="$(SrcFolder)\Plugins\Plugin.*\*.csproj" />
  </ItemGroup>
  <Target Name="BuildPlugins">
    <Message Text="Building Plugins" />
    <MSBuild Projects="@(PluginProjectsFiles)" Targets="Clean;Build" Properties="Configuration=Release" />
    <Message Text="Plugins Built" />
  </Target>

I then changed my DependsOnTargets attribute on my primary build target to my 'BuildPlugins' target. Hope this helps someone as this cause me considerable pain.

Upvotes: 3

Related Questions