Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 385 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to automatically publish a website on build in Visual Studio 2008?

#1
I want to be able to automatically publish to a local folder each time a web asp.net mvc 2 project is built.

I use Visual Studio 2008.
Reply

#2
Well you could do it [with MSBuild][1] in a post-build event.

But are you sure you want to do this? It will slow you down, and you probably don't need to publish for every build? Why not just run the site in IIS instead of Cassini.


[1]:

[To see links please register here]

Reply

#3
Option 1: Switch from Cruise Control to JetBrains TeamCity (you won't regret it!). In TeamCity there's an Artifacts option which ...

"Artifacts are files produced by a build. After finishing a build, TeamCity searches for artifacts in the build's checkout directory according to the specified artifact patterns. Matching files are then uploaded to the server, where they become available for download."

Option 2: Create a task in Cruise Control to do an XCOPY after the build is complete.

<tasks>
<msbuild>
... here's your main build ...
</msbuild>

<exec>
... define your XCOPY or other executable task here ...
<buildTimeoutSeconds>900</buildTimeoutSeconds>
</exec>

Option 3: Create a post-build project in your solution and have a task in it to copy the files over, add a condition on that task that to only trigger when running on cruise control (various environment variables enable this).
Reply

#4
Here is how I do it in my web site project. Note that this will copy to a folder; if you want to publich through FTB, WebDav or SSH, you need to use the `Exec` task instead of the `Copy` task and specify a command-line tool that can deploy the files over the desired protocol.

Also, you can't edit the `AfterBuild` task from the project settings in the VS IDE. You need to open it in Notepad or your favorite text/XML editor. (You could even use VS, if you close the solution and enforce it to open the file with the XML editor :-))

There's also a build target that invokes the `AspNetCompiler`, which I have currently turned off, but you could easily turn on through the `MvcBuildViews` property value.

<PropertyGroup>
<MvcBuildViews>false</MvcBuildViews>
<DropPath>..\..\drop\</DropPath>
</PropertyGroup>
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
</Target>
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
<ConvertToAbsolutePath Paths="$(DropPath)">
<Output TaskParameter="AbsolutePaths" ItemName="FullDropPath" />
</ConvertToAbsolutePath>
<Message Importance="High" Text="Binplacing -> @(FullDropPath)" />
<ItemGroup>
<Binaries Include="$(OutputPath)**\*.*" />
</ItemGroup>
<Copy SkipUnchangedFiles="True" SourceFiles="@(Compile)" DestinationFiles="@(Compile->'$(DropPath)%(Identity)')" />
<Copy SkipUnchangedFiles="True" SourceFiles="@(Content)" DestinationFiles="@(Content->'$(DropPath)%(Identity)')" />
<Copy SkipUnchangedFiles="True" SourceFiles="@(EntityDeploy)" DestinationFiles="@(EntityDeploy->'$(DropPath)%(Identity)')" />
<Copy SkipUnchangedFiles="True" SourceFiles="@(Binaries)" DestinationFiles="@(Binaries->'$(DropPath)%(Identity)')" />
</Target>
Reply

#5
The easiest way to automate the functionality included in Visual Studio's "publish" action available from the Build menu is to use the [web deployment project][1]. There's one for VS2005 as well. Basically it's an extra project that you add to your solution that will target your web project and when built will publish your web project as part of the build process. It makes it dirt simple to automatically build a site as part of build without mucking with MSBuild (though MSBuild isn't that difficult).


[1]:

[To see links please register here]

Reply

#6
Step 1.
Make sure that you have a web project.

Step 2.
Go to View->Toolbars->Web One Click Publish.

The publish button web button on the toolbar will do what you want... build and publish in one step.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through