Asp.net 如何从命令行(或在tfs自动构建中)模拟VS 2012“发布网站”?

Asp.net 如何从命令行(或在tfs自动构建中)模拟VS 2012“发布网站”?,asp.net,visual-studio-2012,tfs,msbuild,Asp.net,Visual Studio 2012,Tfs,Msbuild,我有一个网站,它在本地我的计算机上的一个文件夹中。它没有.csproj,只有文件夹中的所有文件。我想在自动构建中发布网站,这基本上与在命令行中使用msbuild.exe和\或msdeploy.exe和\或aspnet_compiler.exe和/或其他任何东西一样 如果您想创建一个类似这样的项目,以便可以创建一个空的解决方案,请在组合框的按钮上添加->新建网站选择文件系统,添加一个空的类文件,右键单击解决方案资源管理器中的网站行,在解决方案行下,发布网站,在这里,您需要创建一个新的概要文件-非常

我有一个网站,它在本地我的计算机上的一个文件夹中。它没有.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>

我尝试过,但它似乎只适用于web项目,而不适用于网站项目。我没有它需要的*.csproj文件。当我在解决方案文件中执行此操作时,它只是对解决方案进行了常规构建。对不起,我现在已经运行了一个示例项目,并添加了使其工作的步骤。我还有许多项目要构建,因此无法像这样完成,因为其他项目都编译为DLL等。我将检查并查看它是否单独在该项目上工作,如果工作正常,我将检查RunMsbuil活动正在获取和将使用的参数试着用这个。我对VS trail的订阅已经结束,我将在本周修复它,希望能让你知道它是如何运行的。。。