A blog about SQL Server, SSIS, C# and whatever else I happen to be dealing with in my professional life.

Find ramblings

Monday, September 14, 2009

Visual studio build macros

We defined Post-build events for one of our SSIS components .NET projects. Nothing terribly fancy, it just registers the signed assembly in the GAC and pushes it to the Tasks and Pipleine folders for use in the toolbox. As part of our migration from VS 2005 to 2008, I had to rework the events as they were hard coded for 05.

If one right clicks on a project, you can define your pre and post build events. The links below further link to more information if that doesn't give you enough to go on. My challenge was given all the possible macros, which ones did I want? Was it DevEnvDir, FrameworkDir, or FrameworkSDKDir. In the event builder dialogue, there is a Macros >> which results in the following but it only lists what is defined

Sample values for Macros for Build Commands and Properties Your
mileage may vary

http://msdn.microsoft.com/en-us/library/c02as0cs(VS.71).aspx
http://msdn.microsoft.com/en-us/library/c02as0cs.aspx

This was our original post-build scneario. It would force the custom component dll to be registered with the GAC. That DLL contains both data flow task components as well as control flow items so for developers to use it, it needs to exist in the PipelineComponents folder as well as the Tasks folder. We copy it to the Framework folder so it can be picked up for Script tasks and finally, we copy push a template package into the VS folder so it shows as template. As part of the migration from SQL Server 2005 to 2008, the only real change we had to make from a post-build perspective was to make the 90 folders 100. However, the virtual I was working on didn't have gacutil in the path. It seemed silly to update the path to navigate to the executable and so I started digging through the available macros



gacutil -iF "$(TargetPath)"
copy /y "$(TargetPath)" "$(ProgramFiles)\Microsoft SQL Server\90\DTS\PipelineComponents"
copy /y "$(TargetPath)" "$(ProgramFiles)\Microsoft SQL Server\90\DTS\Tasks"
copy /y "$(TargetPath)" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727"
copy /y "$(SolutionDir)\SQL\SSIS\PackageTemplate.dtsx" "$(DevEnvDir)\PrivateAssemblies\ProjectItems\DataTransformationProject\DataTransformationItems"

becomes

"$(FrameworkSDKDir)bin\gacutil.exe" -u "$(TargetName)"
"$(FrameworkSDKDir)bin\gacutil.exe" -i "$(TargetFileName)"
copy /y "$(TargetPath)" "$(ProgramFiles)\Microsoft SQL Server\100\DTS\PipelineComponents"
copy /y "$(TargetPath)" "$(ProgramFiles)\Microsoft SQL Server\100\DTS\Tasks"
copy /y "$(TargetPath)" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727"
copy /y "$(SolutionDir)\SQL\SSIS\PackageTemplate.dtsx" "$(DevEnvDir)\PrivateAssemblies\ProjectItems\DataTransformationProject\DataTransformationItems"


Using this as my Post-Event scenario

echo RemoteMachine = $(RemoteMachine)
echo References = $(References)
echo ConfigurationName = $(ConfigurationName)
echo PlatformName = $(PlatformName)
echo Inherit = $(Inherit)
echo NoInherit = $(NoInherit)
echo StopEvaluating = $(StopEvaluating)
echo ParentName = $(ParentName)
echo RootNameSpace = $(RootNameSpace)
echo IntDir = $(IntDir)
echo OutDir = $(OutDir)
echo DevEnvDir = $(DevEnvDir)
echo InputDir = $(InputDir)
echo InputPath = $(InputPath)
echo InputName = $(InputName)
echo InputFileName = $(InputFileName)
echo InputExt = $(InputExt)
echo ProjectDir = $(ProjectDir)
echo ProjectPath = $(ProjectPath)
echo ProjectName = $(ProjectName)
echo ProjectFileName = $(ProjectFileName)
echo ProjectExt = $(ProjectExt)
echo SolutionDir = $(SolutionDir)
echo SolutionPath = $(SolutionPath)
echo SolutionName = $(SolutionName)
echo SolutionFileName = $(SolutionFileName)
echo SolutionExt = $(SolutionExt)
echo TargetDir = $(TargetDir)
echo TargetPath = $(TargetPath)
echo TargetName = $(TargetName)
echo TargetFileName = $(TargetFileName)
echo TargetExt = $(TargetExt)
echo VSInstallDir = $(VSInstallDir)
echo VCInstallDir = $(VCInstallDir)
echo FrameworkDir = $(FrameworkDir)
echo FrameworkVersion = $(FrameworkVersion)
echo FrameworkSDKDir = $(FrameworkSDKDir)
echo WebDeployPath = $(WebDeployPath)
echo WebDeployRoot = $(WebDeployRoot)
echo SafeParentName = $(SafeParentName)
echo SafeInputName = $(SafeInputName)
echo SafeRootNamespace = $(SafeRootNamespace)
echo FxCopDir = $(FxCopDir)

generates the following


------ Build started: Project: MacroExposition, Configuration: Debug
Any CPU ------
MacroExposition ->
C:\sandbox\MacroExposition\MacroExposition\bin\Debug\MacroExposition.exe
echo RemoteMachine =
echo References =
echo ConfigurationName = Debug
echo PlatformName = AnyCPU
echo Inherit =
echo NoInherit =
echo StopEvaluating =
echo ParentName =
echo RootNameSpace = MacroExposition
echo IntDir =
echo OutDir = bin\Debug\
echo DevEnvDir = C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\
echo InputDir =
echo InputPath =
echo InputName =
echo InputFileName =
echo InputExt =
echo ProjectDir = C:\sandbox\MacroExposition\MacroExposition\
echo ProjectPath =
C:\sandbox\MacroExposition\MacroExposition\MacroExposition.csproj
echo ProjectName = MacroExposition
echo ProjectFileName = MacroExposition.csproj
echo ProjectExt = .csproj
echo SolutionDir = C:\sandbox\MacroExposition\
echo SolutionPath = C:\sandbox\MacroExposition\MacroExposition.sln
echo SolutionName = MacroExposition
echo SolutionFileName = MacroExposition.sln
echo SolutionExt = .sln
echo TargetDir = C:\sandbox\MacroExposition\MacroExposition\bin\Debug\
echo TargetPath =
C:\sandbox\MacroExposition\MacroExposition\bin\Debug\MacroExposition.exe
echo TargetName = MacroExposition
echo TargetFileName = MacroExposition.exe
echo TargetExt = .exe
echo VSInstallDir =
echo VCInstallDir =
echo FrameworkDir = c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
echo FrameworkVersion =
echo FrameworkSDKDir = C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\
echo WebDeployPath =
echo WebDeployRoot =
echo SafeParentName =
echo SafeInputName =
echo SafeRootNamespace =
echo FxCopDir =


RemoteMachine =
References =
ConfigurationName = Debug
PlatformName = AnyCPU
Inherit =
NoInherit =
StopEvaluating =
ParentName =
RootNameSpace = MacroExposition
IntDir =
OutDir = bin\Debug\
DevEnvDir = C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\
InputDir =
InputPath =
InputName =
InputFileName =
InputExt =
ProjectDir = C:\sandbox\MacroExposition\MacroExposition\
ProjectPath = C:\sandbox\MacroExposition\MacroExposition\MacroExposition.csproj
ProjectName = MacroExposition
ProjectFileName = MacroExposition.csproj
ProjectExt = .csproj
SolutionDir = C:\sandbox\MacroExposition\
SolutionPath = C:\sandbox\MacroExposition\MacroExposition.sln
SolutionName = MacroExposition
SolutionFileName = MacroExposition.sln
SolutionExt = .sln
TargetDir = C:\sandbox\MacroExposition\MacroExposition\bin\Debug\
TargetPath = C:\sandbox\MacroExposition\MacroExposition\bin\Debug\MacroExposition.exe
TargetName = MacroExposition
TargetFileName = MacroExposition.exe
TargetExt = .exe
VSInstallDir =
VCInstallDir =
FrameworkDir = c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
FrameworkVersion =
FrameworkSDKDir = C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\
WebDeployPath =
WebDeployRoot =
SafeParentName =
SafeInputName =
SafeRootNamespace =
FxCopDir =
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

And for what it's worth, this is what the virtual kicked out

echo RemoteMachine = 
echo References =
echo ConfigurationName = Debug
echo PlatformName = AnyCPU
echo Inherit =
echo NoInherit =
echo StopEvaluating =
echo ParentName =
echo RootNameSpace = WR.Common.SSIS
echo IntDir =
echo OutDir = .\bin\Debug\
echo DevEnvDir = D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\
echo InputDir =
echo InputPath =
echo InputName =
echo InputFileName =
echo InputExt =
echo ProjectDir = C:\Src\SalesReporting\Src\CommonSSIS\
echo ProjectPath = C:\Src\SalesReporting\Src\CommonSSIS\CommonSSIS.csproj
echo ProjectName = CommonSSIS
echo ProjectFileName = CommonSSIS.csproj
echo ProjectExt = .csproj
echo SolutionDir = C:\src\SalesReporting\Src\CommonSSIS\
echo SolutionPath = C:\src\SalesReporting\Src\CommonSSIS\CommonSSIS.sln
echo SolutionName = CommonSSIS
echo SolutionFileName = CommonSSIS.sln
echo SolutionExt = .sln
echo TargetDir = C:\Src\SalesReporting\Src\CommonSSIS\bin\Debug\
echo TargetPath = C:\Src\SalesReporting\Src\CommonSSIS\bin\Debug\WRCommonSSIS.dll
echo TargetName = WRCommonSSIS
echo TargetFileName = WRCommonSSIS.dll
echo TargetExt = .dll
echo VSInstallDir =
echo VCInstallDir =
echo FrameworkDir = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
echo FrameworkVersion =
echo FrameworkSDKDir = C:\Program Files\Microsoft SDKs\Windows\v6.0A\
echo WebDeployPath =
echo WebDeployRoot =
echo SafeParentName =
echo SafeInputName =
echo SafeRootNamespace =
echo FxCopDir =
RemoteMachine =
References =
ConfigurationName = Debug
PlatformName = AnyCPU
Inherit =
NoInherit =
StopEvaluating =
ParentName =
RootNameSpace = WR.Common.SSIS
IntDir =
OutDir = .\bin\Debug\
DevEnvDir = D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\
InputDir =
InputPath =
InputName =
InputFileName =
InputExt =
ProjectDir = C:\Src\SalesReporting\Src\CommonSSIS\
ProjectPath = C:\Src\SalesReporting\Src\CommonSSIS\CommonSSIS.csproj
ProjectName = CommonSSIS
ProjectFileName = CommonSSIS.csproj
ProjectExt = .csproj
SolutionDir = C:\src\SalesReporting\Src\CommonSSIS\
SolutionPath = C:\src\SalesReporting\Src\CommonSSIS\CommonSSIS.sln
SolutionName = CommonSSIS
SolutionFileName = CommonSSIS.sln
SolutionExt = .sln
TargetDir = C:\Src\SalesReporting\Src\CommonSSIS\bin\Debug\
TargetPath = C:\Src\SalesReporting\Src\CommonSSIS\bin\Debug\WRCommonSSIS.dll
TargetName = WRCommonSSIS
TargetFileName = WRCommonSSIS.dll
TargetExt = .dll
VSInstallDir =
VCInstallDir =
FrameworkDir = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
FrameworkVersion =
FrameworkSDKDir = C:\Program Files\Microsoft SDKs\Windows\v6.0A\
WebDeployPath =
WebDeployRoot =
SafeParentName =
SafeInputName =
SafeRootNamespace =
FxCopDir =

No comments: