user2067567
user2067567

Reputation: 3803

Visual Studio Post build command line Deployment

In Visual Studio am creating a post-build event for Deploying using

md "$(SolutionDir)Deploy\bin"

which created the bin folder inside Deploy folder, inside my Solution.

How do I point this to the folder in some remote machine (where I have the web server)?

$(SolutionDir) to some other folder on a remote machine?

It may look simple to you. :) This is the first time am trying this stuff.

Thanks

Upvotes: 0

Views: 256

Answers (2)

Piotr Stapp
Piotr Stapp

Reputation: 19830

The easiest way is to replace $(SolutionDir) with \\server\share

Upvotes: 2

granadaCoder
granadaCoder

Reputation: 27842

Just as an alternative, I like to keep my .sln and .csproj files "clean".

Then use a second (mini) .msbuild ( which is just a .xml file) to build the .sln, and then do these copy type events as a second action.

Here is a basic example:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapper">

    <PropertyGroup>
        <WorkingCheckout>.</WorkingCheckout>
        <WorkingOutputs>m:\working\outputs</WorkingOutputs>
    </PropertyGroup>

    <Target Name="AllTargetsWrapper">
        <CallTarget Targets="Clean" />
        <CallTarget Targets="Build" />
        <CallTarget Targets="CopyItUp" />
    </Target>

    <Target Name="Clean">

        <RemoveDir Directories="$(WorkingOutputs)" />
        <MakeDir Directories="$(WorkingOutputs)" />

        <Message Text="Cleaning done" />

    </Target>

    <Target Name="Build">
        <MSBuild Projects="$(WorkingCheckout)\MySolution.sln" Targets="Build" Properties="Configuration=$(Configuration)">
            <Output TaskParameter="TargetOutputs" ItemName="TargetOutputsItemName"/>
        </MSBuild>
        <Message Text="Build completed" />
    </Target>

    <!--  -->
    <Target Name="CopyItUp" >

        <ItemGroup>
            <MyExcludeFiles Include="$(WorkingCheckout)\**\SuperSecretStuff.txt" />
            <MyExcludeFiles Include="$(WorkingCheckout)\**\SuperSecretStuff.doc" />
        </ItemGroup>

        <ItemGroup>
            <MyIncludeFiles Include="$(WorkingCheckout)\MyCsProject\bin\$(Configuration)\**\*.*" Exclude="@(MyExcludeFiles)"/>
        </ItemGroup>        


        <Copy
                SourceFiles="@(MyIncludeFiles)"
                DestinationFiles="@(MyIncludeFiles->'$(WorkingOutputs)\%(RecursiveDir)%(Filename)%(Extension)')"
        /> 

    </Target>

</Project>

Upvotes: 1

Related Questions