0

i want to deploy mvc web site that build with visual studio,to the specific folder location. how can it done with project post-build event command. enter image description here

when project build should publish website to the specific folder location.

2 Answers2

0

I am assuming project is building successfully & has resolved all external references.

1. First set Target Location for a Directory like below image in web project:

enter image description here

this is optional but better than change debug/release from build path again & again.

2. Add something like below in Post-build events:

copy "$(ProjectDir)\bin\*.*" "c:\check\" 

Hope it helps.

Update

Is this asp.Net mvc Web project or website? Web project can set output path to bin as in step 1. If you don't want that command in step 2 need path of compiled code as first parameter & path where you need to copy as second parameter, wherever they are. It uses copy command which is as old as DOS & Linux. Refer https://technet.microsoft.com/en-in/library/bb490886.aspx for copy command.

Community
  • 1
  • 1
Pranav Singh
  • 17,079
  • 30
  • 77
  • 104
  • 1
    bin doesn't contain relevant publish stuff.need to get publish contain.want to publish that web site. bin folder doesn't contain view scripts etc.. relevant items that use for publish a website – madusankaDBdharmarathne Jan 10 '18 at 10:12
  • bin doesn't contain relevant publish stuff.need to get publish contain.want to publish that web site. bin folder doesn't contain view scripts etc.. relevant items that use for publish a website.as i mention in the question i want to publish website to the folder when debug or build the project. – madusankaDBdharmarathne Jan 10 '18 at 10:19
  • Is this asp.Net mvc Web project or website? Web project can set output path to bin as in step 1. If you don't want that command in step 2 need path of compiled code as first parameter & path where you need to copy as second parameter, wherever they are. – Pranav Singh Jan 10 '18 at 15:14
  • asp.net mvc web project. Output path set to bin but that doesn't containing stuff that need to publish the site.i want to get all stuff need to publish a web. – madusankaDBdharmarathne Jan 11 '18 at 03:51
  • Just try putting path of compiled project there whether it is debug or release accordingly for source. – Pranav Singh Jan 11 '18 at 06:58
0

Two steps:

  1. Create a publishing profile for your project using deploy to file system as a publishing method
  2. On your postbuild event call the msbuild.exe with the DeployOnBuild=true parameter specifying you publishing profile.
Ionut Ungureanu
  • 1,020
  • 1
  • 13
  • 16
  • hi i done that one but thing is when build the project it doesn't stop the build after firing post-build event.it is hanging and not finish the build.have to cancel the build manually. – madusankaDBdharmarathne Jan 10 '18 at 10:28
  • call "$(MSBuildBinPath)\msbuild.exe" "$(ProjectDir)test.csproj" /p:DeployOnBuild=true /p:Configuration=Debug /p:Platform=AnyCPU /p:PublishProfile=Pub – madusankaDBdharmarathne Jan 10 '18 at 10:29
  • doesn't end up the build process when start the build – madusankaDBdharmarathne Jan 10 '18 at 10:30
  • You might have some resource still locked esclusively from the visual studio build. But I must say that the scenario is not very common... I mean, using the publish a release version for any build requested. Not the standard behaviour anyway. Plus, it is a redundant build (one for Debug followed by one for release). It might be more sensible to create an external tool pointing to an msbuild command. – Ionut Ungureanu Jan 10 '18 at 10:35