At my place of work, we have a 'Core' solution containing a number of projects providing different utility functions which are packaged via nuget and published to an internal nuget server. In order to achieve the nuget packaging from our CI, we currently have an MSBuild script that looks like this:
<Exec Command="nuget pack "$(ProjectRoot)\Domain\Domain.csproj" -Properties Configuration=$(Configuration)" />
<Exec Command="nuget pack "$(ProjectRoot)\Logging\Logging.csproj" -Properties Configuration=$(Configuration)" />
<Exec Command="nuget pack "$(ProjectRoot)\Logging.NLog\Logging.NLog.csproj" -Properties Configuration=$(Configuration)" />
<Exec Command="nuget pack "$(ProjectRoot)\Persistence\Persistence.csproj" -Properties Configuration=$(Configuration)" />
<Exec Command="nuget pack "$(ProjectRoot)\Persistence.NHibernate\Persistence.NHibernate.csproj" -Properties Configuration=$(Configuration)" />
We have about 20 projects being packed this way, and every time we introduce a new project to be packed we have to add another line to the MSBuild script. Is it possible to enumerate the projects in a solution using MSbuild, and thus condense this script into something like...
<foreach project in solution>
<Exec Command="nuget pack project -Properties Configuration=$(Configuration)" />
</foreach>
Additionally, we'd need to be able to interrogate each project in the loop to exclude test projects (these are all under a Tests directory so should be trivial?)
EDIT: Other questions deal with the issue of executing msbuild tasks in a loop, but the solutions involve manually enumerating the items to be looped upon in an ItemGroup, so would result in slightly simpler but still very verbose code. I want to avoid enumerating the projects by hand if possible.