Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify root folder for Package target?

Tags:

msbuild

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.

like image 769
Petr Behenský Avatar asked Jun 11 '12 15:06

Petr Behenský


1 Answers

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

like image 98
Ilya Kozhevnikov Avatar answered Oct 14 '22 18:10

Ilya Kozhevnikov