My web project in Visual Studio 2010 has post-build events that copies files from a folder into the bin directory of the web project. But when I publish my site, MSBuild seems to ignore the post-build events and these files are NOT copied.
The solution is to create a BAT file that executes from a MSBuild Target. I called my BAT file PostBuildEventPublish.bat and it lives in my solution folder. This is the BAT file contents:
xcopy "%1References\UmbracoCourier.lic" "%2" /y
xcopy "%1References\jumps.umbraco.usync.dll" "%2" /y
The parameters %1 and %2 are input from the MSBuild csproj file. In VS2010 unload your web project and edit the project then insert this Target (at the bottom):
<Target Name="AfterPublish" AfterTargets="CopyAllFilesToSingleFolderForPackage">
<Exec Command="$(SolutionDir)References\PostBuildEventPublish.bat "$(SolutionDir)" "$(ProjectDir)obj\$(Configuration)\Package\PackageTmp\bin"" />
<Message Importance="Normal" Text="Finished PostBuildEventPublish.bat" />
</Target>
Obviously change to the paths you want to use.
As you can see parameter %1 = $(SolutionDir)
and parameter %2 = $(ProjectDir)obj\$(Configuration)\Package\PackageTmp\bin
You will notice that my Target always gets executed before the actual publish files are copied.
C:\Dev\Puma\Main\References\PostBuildEventPublish.bat "C:\Dev\Main\" "C:\Dev\Puma\Main\Web\obj\Debug\Package\PackageTmp\bin"
C:\Dev\Puma\Main\References\UmbracoCourier.lic
1 File(s) copied
C:\Dev\Puma\Main\References\jumps.umbraco.usync.dll
1 File(s) copied
Finished PostBuildEventPublish.bat
Publish Pipeline Deploy phase Pre-Deploy CopyAllFilesToOneFolder Stage
Deleting existing files...
Publishing folder /...
Publishing folder App_Browsers...
Publishing folder App_Data...
Publishing folder App_Data/packages...
Publishing folder App_Data/packages/created...
Publishing folder App_Data/packages/installed...
...
Publishing folder uSync/Template/ZMag...
Publishing folder Views...
========== Build: 5 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
So parameter %2 is where the magic happens. Here we copy the files into the temp publish folder and when Publish completes copying the files to the actual Publish folder these post-build files will also be copied.
Showing posts with label Events. Show all posts
Showing posts with label Events. Show all posts
Friday, 14 March 2014
Friday, 10 October 2008
How to: Inherit master page events, methods, properties in a child master page
The easiest way to access events, methods, or properties on a parent master page within a child master page is to use an interface.
Master Pages
Create all common functionlity in a parent master page i.e. Parent.master
Now create your child master page i.e Child.master with it's master page set to Parent.master
Create an interface with a property/method/event you wish to set at parent level and access at child level.
Master Pages
Create all common functionlity in a parent master page i.e. Parent.master
Now create your child master page i.e Child.master with it's master page set to Parent.master
<%@ Master Language="C#" MasterPageFile="Parent.master" AutoEventWireup="true" CodeFile="Child.master.cs" Inherits="Child" %>
InterfaceCreate an interface with a property/method/event you wish to set at parent level and access at child level.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PageInterfaces
{
public interface IMasterPage
{
string hello { get; set; }
}
}
Child.masterpublic partial class Parent : System.Web.UI.MasterPage, IMasterPage
{
public string hello { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
hello = "Hello World!";
}
}
Labels:
Child,
Events,
Inherit,
Master Page,
Methods,
Properties
Subscribe to:
Posts (Atom)