3

I have a ASP.NET Webforms Website project(note this is NOT WebApplication project i.e. there is no .csproj).

I want to do a auto deploy, file system to our network share.

I created a profile and so there is website.publishproj file and profile xml.

I tried adding this in MSBuild arguments in Build Definition:

website.publishproj /p:DeployOnBuild=true /p:PublishProfile=MyDevProfile /p:VisualStudioVersion=12.0

I get this error:

MSBUILD : error MSB1008: Only one project can be specified. Switch: website.publishproj

Any idea what am I doing wrong? I believe this has something to do with Website project type.

This is something I read: How to use command line msbuild to deploy VS2012 Web Site project without precompiling it?

Here is the command:

C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe /nologo /noconsolelogger "E:\Builds\1\TP1\MyWebsite_Dev\src\Websites\MyWebsite\MyWebsite.sln" /nr:False /fl /flp:"logfile=E:\Builds\1\TP1\MyWebsite_Dev\src\Websites\MyWebsite\MyWebsite.log;encoding=Unicode;verbosity=normal" /p:SkipInvalidConfigurations=true website.publishproj /p:DeployOnBuild=true /p:PublishProfile=DropToDemoProfile /p:VisualStudioVersion=12.0 /m /p:OutDir="E:\Builds\1\TP1\MyWebsite_Dev\bin\" /p:VCBuildOverride="E:\Builds\1\TP1\MyWebsite_Dev\src\Websites\MyWebsite\MyWebsite.sln.vsprops" /dl:WorkflowCentralLogger,"C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;BuildUri=vstfs:///Build/Build/35;IgnoreDuplicateProjects=False;InformationNodeId=13;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;LogWarnings=True;TFSUrl=http://mytfs:8080/tfs/colletionname;"*WorkflowForwardingLogger,"C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;" /p:BuildId="7d23530d-7349-406f-98b7-5d4f0b9f4101,vstfs:///Build/Build/35" /p:BuildLabel="MyWebsite_Dev_20141122.13" /p:BuildTimestamp="Sun, 23 Nov 2014 01:22:05 GMT" /p:BuildSourceVersion="LMyWebsite_Dev_20141122.13@$/TP1" /p:BuildDefinition="MyWebsite_Dev"

mlhDev
  • 2,235
  • 1
  • 22
  • 43
gbs
  • 7,196
  • 5
  • 43
  • 69

2 Answers2

2

You're trying to build the solution (MyWebsite.sln) and the project (website.publishproj) simultaneously as part of the same MSBuild command at least according to the arguments being passed.

You can run msbuild website.publishproj /pp:website.pp.publishproj to see what targets you can call in website.pp.publishproj or what properties to override.

You can run set MSBUILDEMITSOLUTION=true && msbuild MyWebsite.sln to see what targets you can call in MyWebsite.sln.metaproj and MyWebsite.metaproj or what properties to override.

Your DeployOnBuild command is fine and should work, I'm guessing your TFS build config is pointing to the .sln and passing website.publishproj as an argument rather than the primary target of the build, so either repoint it to build the .publishproj directly or... well, there doesn't seem to be any alternative, you can try adding a new configuration and editing the .sln with new AspNetConfiguration and MyDevProfile.AspNetCompiler.TargetPath but then you're just asking for trouble.

Ilya Kozhevnikov
  • 10,242
  • 4
  • 40
  • 70
  • The first para makes sense. For the 2nd and 3rd para I don't get that. Haven't done much with msbuild. 4th Para - I did try adding the website.publishproj to the build projects list but it wasn't working as well. I don't recall the error, but I can try again and post. Say I add a .targets file at the solution level and want to add afterbuild target, what would the command look like? Can I set postbuild script in TFS? If yes, what would that script look like? Thanks. – gbs Nov 26 '14 at 18:51
  • @gbs post the error from `publishproj` build. 2/3 are commands you might use to *preparse* the `publishproj` and *emit* the `sln` if you want to read through what is actually being executed by MSBuild and see all the targets that can be called, properties available to override, etc. Yes, you can have a custom build script and all the targets and events you want that in turn build the `sln` and `publishproj`, why not, command remains the same, just pass the filename to MSBuild or configure TFS to build that instead. – Ilya Kozhevnikov Nov 27 '14 at 12:21
  • I tried again with adding .publishproj to the build process and removed it from the build argument. Now it seems it's trying to deploy to my path: \\devserver\www\dropbuild\mywebsite but it is giving Access denied to that path. I actually gave permission to Everyone to that folder not sure what am I missing. – gbs Dec 02 '14 at 04:22
  • never mind...I added everyone but forgot to grant full control. But now what is the right way to grant access to that folder instead of using Everyone. Do I create a separate account and have TFS Build run under that account? – gbs Dec 02 '14 at 04:33
  • @gbs yes, or you can grant it to whichever account agent service is running under, normally Network Service. – Ilya Kozhevnikov Dec 02 '14 at 07:50
  • Is Network Service available outside of the host machine? And is it a good idea to give permission to that account? – gbs Dec 02 '14 at 17:24
  • @gbs yes, if it's on a domain; not it is not, but sometimes creating a dedicated service account in a big todo in a corporate environment. – Ilya Kozhevnikov Dec 02 '14 at 17:27
0

You need to upgrade your Web Site to a Web Application in order for any of this to be automatic.

Its a fairly simple procedure and even on sites with thousands of pages I have completed the migration in only a few days of one persons time without impacting other devs.

Web Site functionality has been feature complete for over 10 years. While it still existing in the product for back-compat I would not recommend using it.

  • Yes, but until then do you see anything wrong in the above command? Most my findings points to space in the path which I couldn't find. The build arguments way did work for me in one of my test website but not with my real website. – gbs Nov 23 '14 at 16:59