I m running MSBuild script to compile my project and iv set a artifact path in the general settings of TeamCity. My MSBuild scripts first build and then creates a zip file. I would like to add that zip file as a artifact but when i run the build on TeamCity i get this error:
[17:44:56]: [CreateNightlyZip] Zip
[17:44:56]: [Zip] C:\BuildAgent\Build\Build.proj(55, 5): The process cannot access the file 'C:\BuildAgent\work\c13cf8f192b25cd1\bin\Debug\20120109_Foo.PE.zip' because it is being used by another process.
So it lookes like TeamCity tries to grab the zip file right when its created and then my MSBuild script fails to put files into it.
Here is the MSBuild target:
<Target Name="CreateNightlyZip">
<PropertyGroup>
<StringDate>$([System.DateTime]::Now.ToString('yyyyMMdd'))</StringDate>
</PropertyGroup>
<ItemGroup>
<DebugApplicationFiles Include="$(DebugPath)\**\*.*" Exclude="$(DebugPath)\*vshost.exe*" />
</ItemGroup>
<MakeDir Directories="$(NightlyBuildPath)"/>
<Zip Files="@(DebugApplicationFiles)"
WorkingDirectory="$(DebugPath)"
ZipFileName="$(NightlyBuildPath)\$(StringDate)_$(NightlyZipName).zip"
ZipLevel="9" />
</Target>
Have anybody had this problem allso or what should be solution for this?
EDIT: What is strange is that when i create zip file in the root of checkout folder then everything works, but when i create it to the Debug folder then i get this error.