[英]How can I mimic the VS 2012 “publish webSite” from command line (or in tfs automated build)?
我有一個WebSite,它位於計算機上的本地文件夾中。 它沒有.csproj-只是文件夾中的所有文件。 我想以自動構建的方式來發布網站,基本上就像在命令行中使用msbuild.exe和/或msdeploy.exe和/或aspnet_compiler.exe和/或其他任何方式來進行。
如果要創建一個類似這樣的項目,則可以創建一個空的解決方案,請添加->新網站(在組合框的底部選擇文件系統),添加一個空的類文件,右鍵單擊解決方案資源管理器中的網站行,在在解決方案行“發布網站”上,您需要在其中創建一個新的配置文件-真的很簡單-基本上選擇“文件系統”,然后發布。
我在VS2012更新4上運行。
如果您傳遞的MSbuild參數為
/p:DeployOnBuild=true;PublishProfile=PROFILENAME
如果您的個人資料設置正確,它應該與從VS發布相同
編輯
抱歉,只需要執行其中一項操作即可查看會發生什么情況
當您將網站簽入TFS時,它會創建一個網站文件夾。
然后,您可以將構建映射到該文件夾。
您可以指向publishproj文件,而不是將構建映射到sln文件,而是在創建發布配置文件時創建該文件。 這告訴構建該做什么
在此方法中,我將發布位置設置為c:\\ publish,在構建后,我將輸出保存在名為c:\\ publish的文件夾中。
生成的publishproj文件如下所示
<?xml version="1.0" encoding="utf-8"?>
<!--
***********************************************************************************************
website.publishproj
WARNING: DO NOT MODIFY this file, it is used for the web publish process.
Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.30319</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{f17a9da4-9b68-41e4-ab73-5ac72898b384}</ProjectGuid>
<SourceWebPhysicalPath>$(MSBuildThisFileDirectory)</SourceWebPhysicalPath>
<SourceWebVirtualPath>/WebSite1</SourceWebVirtualPath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<SourceWebProject>http://localhost:61874</SourceWebProject>
<SourceWebMetabasePath>/IISExpress/7.5/LM/W3SVC/15/ROOT</SourceWebMetabasePath>
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<!-- for VS2010 we need to use 10.5 but for VS2012+ we should use VisualStudioVersion -->
<WebPublishTargetsVersion Condition=" '$(WebPublishTargetsVersion)' =='' and '$(VisualStudioVersion)' == 10.0 ">10.5</WebPublishTargetsVersion>
<WebPublishTargetsVersion Condition=" '$(WebPublishTargetsVersion)'=='' ">$(VisualStudioVersion)</WebPublishTargetsVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(WebPublishTargetsVersion)</VSToolsPath>
<_WebPublishTargetsPath Condition=" '$(_WebPublishTargetsPath)'=='' ">$(VSToolsPath)</_WebPublishTargetsPath>
<AssemblyFileVersion Condition="'$(AssemblyFileVersion)' == ''">1.0.0.0</AssemblyFileVersion>
<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">1.0.0.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
<AssemblyAttributes Include="AssemblyFileVersion">
<Value>$(AssemblyFileVersion)</Value>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyVersion">
<Value>$(AssemblyVersion)</Value>
</AssemblyAttributes>
</ItemGroup>
<Import Project="$(_WebPublishTargetsPath)\Web\Microsoft.WebSite.Publishing.targets" />
</Project>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.