代码之家  ›  专栏  ›  技术社区  ›  CubanX

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

  •  45
  • CubanX  · 技术社区  · 14 年前

    各位,

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

    这是一个Visual Studio 2010 ASP.Net MVC项目。如果我执行这个命令,我会得到我想要的所有文件,包括“C:\ ToDeploy”目录中转换的web.configs。

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

    我知道我可以使用nAnt任务或rake脚本复制这个功能,但是我想使用这个机制来完成,这样我就不会重复自己了。

    我又调查了一些,发现了这些联系,但没有一个解决得很清楚:

    提前谢谢!

    6 回复  |  直到 7 年前
        1
  •  46
  •   CubanX    13 年前

    好吧,终于弄明白了。

    您需要的命令行是:

    msbuild path/to/your/webdirectory/YourWeb.csproj /p:Configuration=Debug;DeployOnBuild=True;PackageAsSingleFile=False
    

    outdir=c:\wherever\ 在/p:部分。

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

    path/to/your/webdirectory/obj/Debug/Package/PackageTmp/
    

    然后可以使用任何方法从上述目录复制这些文件。

    我把这些都当作ruby rake任务使用 Albacore . 我正在努力把它全部完成,这样我就可以把它作为对项目的贡献。但如果有人想在那之前得到密码,请告诉我。

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

    /p:AutoParameterizationWebConfigConnectionStrings=false
    
        2
  •  11
  •   Community    7 年前

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

    Publish a Web Application from the Command Line ,但刚刚清理并添加了日志文件。同时查看原始来源 http://www.digitallycreated.net/Blog/59/locally-publishing-a-vs2010-asp.net-web-application-using-msbuild

    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=
    

    通过添加以下xml更新Web应用程序项目文件MyWebBasedApp.csproj <Import Project=

    <Target Name="PublishToFileSystem" DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder">
    <Error Condition="'$(PublishDestination)'==''" Text="The PublishDestination property must be set to the intended publishing destination." />
        <MakeDir Condition="!Exists($(PublishDestination))" Directories="$(PublishDestination)" />
    
        <ItemGroup>
            <PublishFiles Include="$(_PackageTempDir)\**\*.*" />
        </ItemGroup>
    
        <Copy SourceFiles="@(PublishFiles)" DestinationFiles="@(PublishFiles->'$(PublishDestination)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="True" />
    </Target>
    

    这比其他解决方案对我更有效。

    有关详细信息,请查看以下内容:

    http://www.digitalycreated.net/Blog/59/locally-publishing-a-vs2010-asp.net-web-application-using-msbuild

    2个)

    三) Build Visual Studio project through the command line

        3
  •  1
  •   Asier    11 年前

    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>
    
        4
  •  1
  •   bubbassauro    10 年前

    publish profiles on your project 对于msbuild 12,这相当于右键单击并发布。。。选择发布配置文件(本例中为“MyProfile”):

    msbuild C:\myproject\myproject.csproj "/P:DeployOnBuild=True;PublishProfile=MyProfile"
    
        5
  •  0
  •   Community    7 年前

    我有一个针对Visual Studio 2012的解决方案: https://stackoverflow.com/a/15387814/2164198

    但是,它在没有安装Visual Studio的情况下工作!(见 更新 我还没有检查是否可以从visualstudioexpress2012中获取所有需要的东西来进行Web安装。

        6
  •  -1
  •   outofcoolnames    12 年前

    一个完整的msbuild文件,灵感来自CubanX

        <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>
    

    推荐文章