MSBuild Community Tasks not found

c#, msbuild, visual-studio-2010

Solution

Sounds like you want multiple build configurations. I would suggest setting up one specifically for building and zipping the artifacts and a separate for your users.

`Release ZIP` could be your build with the post-build-event to zip your files, and `Release` could be an ordinary build that doesn't do anything special using the community tasks.

Problem

I have `MyLib` library project along with several examples. The library and examples are in the same solution `MySolution`. In `MyLib` library project I have included MSBuild code to zip the whole solution and copy to another directory for internet publishing. ``` <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" /> <Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'"> <PropertyGroup> <ReleasePath>C:\Users\Administrator\Projects\CA\Libraries\Api-DotNet\</ReleasePath> <ZipFile>C:\Users\Administrator\Projects\CA\WebProject\libraries\Api-DotNet.zip</ZipFile> </PropertyGroup> <ItemGroup> <LibraryFiles Include="$(ReleasePath)\**\*.*" Exclude="$(ReleasePath)\**\*.user;$(ReleasePath)\**\*.suo;$(ReleasePath)\Api.*;$(ReleasePath)\**\packages\**;$(ReleasePath)\**\Lib.Test\**;$(ReleasePath)\**\*.nuspec;$(ReleasePath)\**\*.nupkg;$(ReleasePath)\**\*nuget*;$(ReleasePath)\**\*internal*;$(ReleasePath)\**\*ReSharper*\**;$(ReleasePath)\**\.svn\**;$(ReleasePath)\**\obj\**;$(ReleasePath)\lib\bin\Debug\**;$(ReleasePath)\lib\bin\Publish\**;$(ReleasePath)\Example\**\bin\**;" /> </ItemGroup> <Zip Files="@(LibraryFiles)" WorkingDirectory="$(ReleasePath)" ZipFileName="$(ZipFile)" ZipLevel="9" /> </Target> </Project> ``` The problem is that when user download library and run on another computer the compiler show error that import library not found `MSBuild.Community.Tasks.Targets`. I would like to exclude ZipAndCopy code from project file when building the solution. How to do that?

Original source

Related problems