Last active
August 29, 2015 14:07
-
-
Save ryepup/0f005f6a4ec2506d3435 to your computer and use it in GitHub Desktop.
snippet of MSBuild for publish COM objects to a remote server using psexec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup Condition="'$(Env)' == 'test'"> | |
<!-- UNC path where we publish code--> | |
<PublishFolder>\\dev-server\Sites\my-classic-asp-site</PublishFolder> | |
<!-- the remote path to where our code is deployed --> | |
<LocalPublishFolder>D:\WebRoot\my-classic-asp-site</LocalPublishFolder> | |
<!-- the computer name for psexec --> | |
<Computer>\\dev-server</Computer> | |
</PropertyGroup> | |
<PropertyGroup Condition="'$(Env)' == 'prod'"> | |
<PublishFolder>\\prod-server\WebRoot\my-classic-asp-site</PublishFolder> | |
<LocalPublishFolder>D:\sites\my-classic-asp-site</LocalPublishFolder> | |
<Computer>\\prod-server</Computer> | |
</PropertyGroup> | |
<PropertyGroup> | |
<!-- where to copy our COM assembly --> | |
<COMPublishFolder>$(PublishFolder)\COM</COMPublishFolder> | |
<!-- remote path to our where we published our COM assembly --> | |
<COMFolder>$(LocalPublishFolder)\COM</COMFolder> | |
<!-- remote path to our COM assembly --> | |
<COMAssembly>$(COMFolder)\My.Interop.dll</COMAssembly> | |
<!-- remote path to our typelib --> | |
<COMTypeLib>$(COMFolder)\My.Interop.tlb</COMTypeLib> | |
<!-- local path to psexec--> | |
<PsExec>$(MSBuildProjectDirectory)\tools\PsExec.exe</PsExec> | |
<!-- remote path to regasm.exe --> | |
<RegAsm>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe</RegAsm> | |
<!-- remote path to iisreset.exe --> | |
<iisreset>c:\WINDOWS\system32\iisreset.exe</iisreset> | |
</PropertyGroup> | |
<Target Name="DeployCOM"> | |
<!-- local path our compiled, strongly-named COM assembly and it's dependencies --> | |
<ItemGroup> | |
<FilesToCopy Include="$(MSBuildProjectDirectory)\src\My.Interop\bin\Release\*.*"/> | |
</ItemGroup> | |
<MakeDir Directories="$(COMPublishFolder)"/> | |
<!-- unregister the old version of the DDL --> | |
<Exec Command="$(PsExecBinary) $(Computer) $(RegAsm) /u /codebase /tlb:$(COMTypeLib) $(COMAssembly)" | |
IgnoreExitCode="true"/> | |
<!-- restart IIS --> | |
<Exec Command="$(PsExecBinary) $(Computer) $(iisreset) /restart" IgnoreExitCode="true"/> | |
<!-- copy new DLL to the server --> | |
<Copy SourceFiles="@(FilesToCopy)" | |
DestinationFiles="@(FilesToCopy->'$(COMPublishFolder)\%(RecursiveDir)%(Filename)%(Extension)')" | |
SkipUnchangedFiles="true" | |
/> | |
<!-- register the new DDL --> | |
<Exec Command="$(PsExecBinary) $(Computer) $(RegAsm) /codebase /tlb:$(COMTypeLib) $(COMAssembly)"/> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment