使用MSBuild构建ASP.Net网站与Visual Studio构建不同

我有一个旧的ASP.Net网站解决方案,看起来像:

使用MSBuild构建ASP.Net网站与Visual Studio构建不同

当我在Visual Studio中构建解决方案时,得到以下输出:

------ Build started: Project: C:\...\XXXX\,Configuration: Debug Any CPU ------

Validating Web Site
Building directory '/XXXX/App_Code/'.
Building directory '/XXXX/App_WebReference/'.
Building directory '/XXXX/js/'.
Building directory '/XXXX/msg/'.
Building directory '/XXXX/z_admin/'.
Building directory '/XXXX/z_emulationDialogs/'.
Building directory '/XXXX/'.

但是当我使用TFS(MSBuild任务)进行构建或使用解决方案运行msbuild.exe时,我会得到另一个输出:

Project "C:\TFSAgent\Agent01\_work\1\s\XXXX\XXXX.sln" on node 1 (default targets).
ValidateSolutionconfiguration:
  Building solution configuration "debug|any cpu".
Project "C:\TFSAgent\Agent01\_work\1\s\XXXX\XXXX.sln" (1) is building "C:\TFSAgent\Agent01\_work\1\s\XXXX\XXXX.metaproj" (2) on node 1 (default targets).

Build:

  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\BarcodePrinter.dll" to "..\XXXX\\Bin\BarcodePrinter.dll".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\IDAutomation.LinearBarCode.dll" to "..\XXXX\\Bin\IDAutomation.LinearBarCode.dll".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\zxing.dll" to "..\XXXX\\Bin\zxing.dll".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\BarcodePrinter.pdb" to "..\XXXX\\Bin\BarcodePrinter.pdb".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\zxing.pdb" to "..\XXXX\\Bin\zxing.pdb".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\zxing.xml" to "..\XXXX\\Bin\zxing.xml".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\System.Net.Http.dll" to "..\XXXX\\Bin\System.Net.Http.dll".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\System.Net.Http.xml" to "..\XXXX\\Bin\System.Net.Http.xml".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\System.Net.Http.Formatting.dll" to "..\XXXX\\Bin\System.Net.Http.Formatting.dll".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\System.Net.Http.Formatting.xml" to "..\XXXX\\Bin\System.Net.Http.Formatting.xml".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\System.Net.Http.WebRequest.dll" to "..\XXXX\\Bin\System.Net.Http.WebRequest.dll".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\System.Net.Http.WebRequest.xml" to "..\XXXX\\Bin\System.Net.Http.WebRequest.xml".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\system.web.Http.dll" to "..\XXXX\\Bin\system.web.Http.dll".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\system.web.Http.xml" to "..\XXXX\\Bin\system.web.Http.xml".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\system.web.Http.WebHost.dll" to "..\XXXX\\Bin\system.web.Http.WebHost.dll".
  Copying file from "C:\TFSAgent\Agent01\_work\1\s\XXXX\bin\system.web.Http.WebHost.xml" to "..\XXXX\\Bin\system.web.Http.WebHost.xml".
  C:\Windows\microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v /XXXX -p ..\XXXX\ -u -f -d PrecompiledWeb\XXXX\

在构建之后,我没有获得所有DLL的问题,如果我在VS中制作publish,我会得到很多DLL(例如App_Code.dll),而这些文件在TFS之后是无法获得的/ MSBuild构建。

我尝试添加/p:DeployOnBuild=true,但没有解决。

那么我如何构建这个项目并准备发布呢?

hbxflihua 回答:使用MSBuild构建ASP.Net网站与Visual Studio构建不同

这是预期的行为。因为您正在尝试使用MSBuild命令来构建网站项目(metaproj)。然后,它创建一个PrecompiledWeb文件夹并将代码放置在其中。

  

在Visual Studio中创建发布配置文件后,以下是   已创建:

     

1)App_Data / PublishProfiles下的发布配置文件(.pubxml文件)

     

2)网站根目录中的 website.publishproj

     

website.publishproj的目的是方便命令行   出版。然后,您可以尝试使用如下命令:

C:\Program Files (x86)\Microsoft Visual Studio 14.0>msbuild "C:\Users\UserName\Documents\Visual Studio2015\WebSites\WebSite1\website.publishproj" /p:deployOnBuild=true /p:publishProfile=WebsiteTestDemo /p:VisualStudioVersion=14.0

请使用website.publishproj代替MSBuild命令和任务,有关更多详细信息,请查看以下问题的答案:Publish Artifacts for website goes to PrecompiledWeb

本文链接:https://www.f2er.com/3109125.html

大家都在问