How to specify root folder for Package target?

msbuild

Solution

You can use `_PackageTempDir` instead of `PackageLocation` for IIS-like flat structure, but if you want to keep the .zip and .cmd with manifests then no, you can't really get away from absolute paths without rewriting Microsoft.Web.Publishing.targets or a custom task due to the way the var is used.

<_PackageTempDir>$(PackageTempRootDir)\PackageTmp</_PackageTempDir>
<_PackageTempDirFullPath>$([System.IO.Path]::GetFullPath($(_PackageTempDir))</_PackageTempDirFullPath>
<_MSDeployDirPath Include="$(_PackageTempDir)" />
<_MSDeployDirPath_FullPath>@(_MSDeployDirPath->'%(FullPath)')</_MSDeployDirPath_FullPath>

You can however trick msbuild and flatten it a little bit by hiding the absolute path with a local share, something like this:

net share foo=D:\Temp
msbuild WebApplication1.csproj /t:Package /p:PackageTempRootDir=\\localhost\foo

That'll change your deep local path to something like `obj\Debug\Package\WebApplication1.zip\Content\_S_Slocalhost_Sfoo\PackageTmp`

Problem

I publish my web application using msbuild by calling following command: ``` msbuild myweb.csproj /T:Package /P:PackageLocation=obj\Output\myweb.zip ``` The content of zip file has always deep folder structure containing full path from drive root to the project folder. Is there any way how to make it more flat? I would like to have a project folder like root in zip.

Original source