Publish ASP.NET web site from command-line bat file, the ultimate .bat file

天涯浪子 提交于 2019-12-12 03:22:53

问题


There are a number of questions here on SO about how to publish ASP.NET web site from command-line (including my own here), but none of them get me to the solution I want:

  • Single output folder as I specified
  • Applied Web.config transformations

I'm getting close to something that works for me, but there are still a couple of issues.
Here is what I have so far:

SET TEMP_PATH=c:\_MyProject\
SET DEST_PATH=%TEMP_PATH%_Output\
SET CSPROJ_PATH=.\MyProject\MyProject.csproj
SET CONFIGURATION=Release
SET LOG_FILE=MyProjectDeploy.log

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe ^
%CSPROJ_PATH% ^
/p:Configuration=%CONFIGURATION%;DeployOnBuild=True;PackageAsSingleFile=False;AutoParameterizationWebConfigConnectionStrings=False ^
/property:OutDir=%TEMP_PATH% ^
/property:WebProjectOutputDir=%DEST_PATH% ^
/l:FileLogger,Microsoft.Build.Engine;logfile=%LOG_FILE%

But my script still has these problems:

  • The version with one Web.config with applied transformation is deep inside folder structure: C:\_MyProject\_PublishedWebsites\MyProject_Package\Archive\Content\C_C\<Long path that replicate my folder structure>\obj\Release\Package\PackageTemp\ The problem that path to the probject is included here, so it cat vary from developer to developer.
  • The version which is located in %DEST_PATH% is what I need but without Web.config transformations

回答1:


It seems that ultimate solution exists:

https://stackoverflow.com/a/3452664/118810

It works for solutions too.



来源:https://stackoverflow.com/questions/9062171/publish-asp-net-web-site-from-command-line-bat-file-the-ultimate-bat-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!