Visual studio 2010 VS2010 Web发布命令行版本的文件系统部署

Visual studio 2010 VS2010 Web发布命令行版本的文件系统部署,visual-studio-2010,command-line,msdeploy,web-publishing,msbuild-wpp,Visual Studio 2010,Command Line,Msdeploy,Web Publishing,Msbuild Wpp,各位 简而言之,我想复制这个对话框: 这是一个VisualStudio2010ASP.NETMVC项目。如果执行此命令,将获得所需的所有文件,包括“C:\ToDeploy”目录中转换的web.configs 我想在命令行上复制它,以便将其用于QA环境构建 我看过关于如何在远程部署的命令行上执行此操作的各种文章,但我只想在文件系统部署中执行此操作 我知道我可以使用nAnt任务或rake脚本复制这个功能,但我想使用这个机制来实现,所以我不会重复我自己 我对此进行了更多的调查,发现了这些链接,但没有

各位

简而言之,我想复制这个对话框:

这是一个VisualStudio2010ASP.NETMVC项目。如果执行此命令,将获得所需的所有文件,包括“C:\ToDeploy”目录中转换的web.configs

我想在命令行上复制它,以便将其用于QA环境构建

我看过关于如何在远程部署的命令行上执行此操作的各种文章,但我只想在文件系统部署中执行此操作

我知道我可以使用nAnt任务或rake脚本复制这个功能,但我想使用这个机制来实现,所以我不会重复我自己

我对此进行了更多的调查,发现了这些链接,但没有一个能很好地解决这个问题:


提前谢谢

好了,终于弄明白了

您需要的命令行是:

msbuild path/to/your/webdirectory/YourWeb.csproj /p:Configuration=Debug;DeployOnBuild=True;PackageAsSingleFile=False
您可以通过在/p:部分中添加
outdir=c:\where\
属性来更改项目输出到的位置

这将在以下位置创建输出:

path/to/your/webdirectory/obj/Debug/Package/PackageTmp/
然后,您可以使用您喜欢的任何方法从上述目录复制这些文件

我使用ruby rake任务实现了这一切。我正在努力把它全部完成,这样我才能真正把它作为对项目的贡献。但是如果有人想在那之前知道密码,请告诉我

我发现的另一个问题是,它将标记化参数放入Web.config。如果不需要该功能,请确保添加:

/p:AutoParameterizationWebConfigConnectionStrings=false

我想我应该发布另一个我发现的解决方案,我已经更新了这个解决方案,包括一个日志文件

这与类似,但只是清理并添加了日志文件。还可以查看原始来源

在web应用程序项目的根目录中创建一个MSBuild\u publish\u site.bat(随便命名)

set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
set destPath=C:\Publish\MyWebBasedApp\

:: clear existing publish folder
RD /S /Q "%destPath%"

call %msBuildDir%\msbuild.exe  MyWebBasedApp.csproj "/p:Configuration=Debug;PublishDestination=%destPath%;AutoParameterizationWebConfigConnectionStrings=False" /t:PublishToFileSystem /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_Publish_LOG.log

set msBuildDir=
set destPath=
通过在

这比其他解决方案更适合我

有关更多信息,请查看以下内容:

(一)

(二)


3)

灵感来自CubanX的完整msbuild文件

    <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="Publish">
        <RemoveDir Directories="..\build\Release\Web\"
                     ContinueOnError="true" />        
       <MSBuild Projects="TheWebSite.csproj"
                Targets="ResolveReferences;_CopyWebApplication"
                Properties="Configuration=Release;WebProjectOutputDir=..\build\Release\Web;OutDir=..\build\Release\Web\bin\"
        />  
    </Target>
    <Target
        Name="Build"
        DependsOnTargets="Publish;">
    </Target>   
</Project>


这会将已发布的网站放置在Web..\build\Release文件夹中

我有一个Visual Studio 2012的解决方案:

但是,它在没有安装Visual Studio的情况下工作!(请参见更新)。
我还没有检查是否可以从Visual Studio Express 2012获取所有需要的Web安装资料。

我的CCNET解决方案通过Web.config转换

<tasks>
    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
        <workingDirectory>E:\VersionesCC\Trunk_4\SBatz\Gertakariak_Orokorrak\GertakariakMS\Web</workingDirectory>
        <projectFile>GertakariakMSWeb2.vbproj</projectFile>
        <targets>Build</targets>
        <timeout>600</timeout>
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
        <buildArgs>
            /noconsolelogger /p:Configuration=Release /v:diag
            /p:DeployOnBuild=true
            /p:AutoParameterizationWebConfigConnectionStrings=false
            /p:DeployTarget=Package
            /p:_PackageTempDir=E:\Aplicaciones\GertakariakMS2\Web
        </buildArgs>
        </msbuild>
</tasks>

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
E:\VersionesCC\Trunk\u 4\SBatz\Gertakariak\u orokorak\GertakariakMS\Web
GertakariakMSWeb2.vbproj
建造
600
C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll
/noconsolelogger/p:Configuration=Release/v:diag
/p:DeployOnBuild=true
/p:AutoParameterizationWebConfigConnectionStrings=false
/p:DeployTarget=Package
/p:_PackageTempDir=E:\Aplicaciones\GertakariakMS2\Web

在VS2012及更高版本上,您可以使用msbuild 12.0引用现有版本,这相当于右键单击并发布。。。选择发布配置文件(本例中为“MyProfile”):


不幸的是,这复制了整个包。我认为您需要使用MS Web Deploy仅复制已更改的文件。为确保完整性,OutDir属性必须以尾部斜杠结尾(否则为MSBuild errors out)。因此,您的建议应该是
outdir=c:\where\
。此外,您可以使用包目标:
/t:Package
而不是
/p:DeployOnBuild=True
。对我来说很有用,而且
packageassingfile
AutoParameterizationWebConfigConnectionStrings
参数也受到尊重。@Jakub我更新了答案以反映OutDir的评论,谢谢!
<tasks>
    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
        <workingDirectory>E:\VersionesCC\Trunk_4\SBatz\Gertakariak_Orokorrak\GertakariakMS\Web</workingDirectory>
        <projectFile>GertakariakMSWeb2.vbproj</projectFile>
        <targets>Build</targets>
        <timeout>600</timeout>
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
        <buildArgs>
            /noconsolelogger /p:Configuration=Release /v:diag
            /p:DeployOnBuild=true
            /p:AutoParameterizationWebConfigConnectionStrings=false
            /p:DeployTarget=Package
            /p:_PackageTempDir=E:\Aplicaciones\GertakariakMS2\Web
        </buildArgs>
        </msbuild>
</tasks>
msbuild C:\myproject\myproject.csproj "/P:DeployOnBuild=True;PublishProfile=MyProfile"