2

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?

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • Which version of Visual Studio are you using locally? And which MSBuild version do you have on TFS? – Pavel Anikhouski Nov 13 '19 at 14:48
  • I tried with Visual Studio 2017 in both (the project originally is 2012 but I tested in my VS 2017 and the build output is the same as 2012) – Shayki Abramczyk Nov 13 '19 at 15:24
  • 1
    I checked again and suddenly I see `PreCompiledWeb` folder that generated by the build, all the DLLs exist there. I didn't notice it before! so I guess I should take the files from there :) – Shayki Abramczyk Nov 13 '19 at 15:28

1 Answers1

1

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

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Thanks @Patrick! can I just take the files from the compiledWeb folder instead of create a `.pubxml` file? – Shayki Abramczyk Nov 14 '19 at 07:02
  • @ShaykiAbramczyk Yeah, theoretically. You could do this since generated dlls are just used for publish. And the `.pubxml` file: 1.Contains publish configuration settings and is consumed by the publishing process. 2.Can be modified to customize the build and publish process. However, this is really not a common situation. We usually directly use vs build task for that kind of old ASP.Net Website solution. Suggest you double check and test in your side. – PatrickLu-MSFT Nov 14 '19 at 07:20
  • VS build task will give me other results rather than msbuild task? – Shayki Abramczyk Nov 14 '19 at 07:35
  • There are almost the same. https://stackoverflow.com/questions/39667822/differences-between-visual-studio-build-step-and-msbuild-build-step However in your case, even you build locally through Visual Studio and MSBuild command line, you will also get different result. That's due to ASP.Net Website solution. Not related to task itself. – PatrickLu-MSFT Nov 14 '19 at 07:44
  • Thank you! I created the `pubxml` file and it works great. – Shayki Abramczyk Nov 14 '19 at 15:06