Shayki Abramczyk
Shayki Abramczyk

Reputation: 41595

Build ASP.Net Website with MSBuild is different from Visual Studio build

I have an old ASP.Net Website solution, that look like:

enter image description here

When I build the solution within the Visual Studio I get the following output:

------ 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/'.

But when I build it with TFS (MSBuild task) or run the msbuild.exe with the solution I got another output:

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\

The problem that I'm not got all the DLLs after this build, if I make publish in the VS I got a lot of DLLs (e.g. App_Code.dll) that I do not get after TFS/MSBuild build.

I tried to add /p:DeployOnBuild=true but does not solve it.

So how can I build this project and prepare it to publish?

Upvotes: 2

Views: 1619

Answers (1)

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51103

That's an expected behavior. Cause you are trying to use MSBuild command to build the website project (metaproj). Then it creates a PrecompiledWeb folder and places the code in there.

After creating a publish profile in Visual Studio the following are created:

1) A publish profile (.pubxml file) under App_Data/PublishProfiles

2) A website.publishproj in the root of the website

The purpose of the website.publishproj is to facilitate command line publishing. Then you can try to use command like the following:

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

Please use website.publishproj instead for MSBuild command and task, for more details info kindly take a look at the answer in this question: Publish Artifacts for website goes to PrecompiledWeb

Upvotes: 1

Related Questions