MsBuild publish website without using publish profile

99封情书 提交于 2019-12-30 06:29:22

问题


A publish profile to publish a Visual Studio Website can be used from both the Visual Studio 2013 publish dialog, and from the command line MsBuild as explained in this question Using msbuild to execute a File System Publish Profile

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe 
./ProjectRoot/MyProject.csproj /p:DeployOnBuild=true /p:PublishProfile=FileSystemDebug

However, I want to get rid of the publish profile completely and do everything from the command line - because I do not want the publish path to be hard-coded in the PublishProfile xml file. How can I specify the same options directly in the command line arguments? I have tried using OutDir instead, but that results in a different behavior than the path specified in the PublishProfile (an extra _PublishedWebsites is appended to my path).


回答1:


You can actually override the PublishProfile settings from the command line. You would want this parameter:

/p:publishUrl=pathToPublishHere

If it's local filesystem this should work just fine.




回答2:


publish.bat

SET PROJECT="D:\Github\MyWebSite.csproj"
SET MSBUILD_PATH="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
SET PUBLISH_DIRECTORY="C:\MyWebsitePublished"

cd /d %MSBUILD_PATH%
MSBuild %PROJECT%  /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=%PUBLISH_DIRECTORY%

needs a Visual Studio to be installed on server.



来源:https://stackoverflow.com/questions/33740592/msbuild-publish-website-without-using-publish-profile

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