20 August 2009

Or, how I learned to read the assembly name

In which I include dll's

I was trying out this tutorial on Geekpedia and the references were invalid. I removed the two (Microsoft.SqlServer.Smo and Microsoft.SqlServer.ConnectionInfo: yes, the dll names are missing the .Management part from the namespace they contain) and re-added them. Simple enough. Then there was an issue with the unreferenced Microsoft.SqlServer.Management.Sdk.Sfc, after running the installers (all just said repairing), I found the dll, but I'm not sure if it was there before. The dll in this case has the same name as the namespace, unlike the previous two dll's which are missing the .Management portion, so I was looking in the wrong part of the list.

In which I question my sanity

All was relatively sane up to this point, then I started to think I was crazy. The Backup class was missing from the namespace. I checked the documentation for Microsoft.SqlServer.Management and sure enough, Backup was there. After turning to google for a while and reading all about people finding and GACing the dll, I headed to %systemroot%/assembly to see what I had. It was at this point that I saw there was a dll Microsoft.SqlServer.SmoExtended. Inquisitively, I added a reference to this dll. And, lo! the classes were found. Looking at the documentation for the Backup class, I now notice:
The Backup object provides programmatic access to Microsoft SQL Server backup operations.
Namespace: Microsoft.SqlServer.Management.Smo
Assembly: Microsoft.SqlServer.SmoExtended (in microsoft.sqlserver.smoextended.dll)

A curious discovery

So, multiple dlls can add classes to the namespace. Who knew? Not me. And, w.r.t. Microsoft.SqlServer.Management.Smo, their structure must have changed somewhere between the dlls that Andrew Pociu (Geekpedia) was using (I'm assuming 9.x) and the 10.0 dlls.

Post-script: local help is outdated

While writing this post, I thought to check my local help where the documentation is out of date, so perhaps I have a valid excuse.

The Backup object provides programmatic access to Microsoft SQL Server backup operations.
Namespace: Microsoft.SqlServer.Management.Smo
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
fin

Posted on Thursday, August 20, 2009 by Unknown

6 comments

26 May 2009

After my last post on building WSP in TFS, I was at a stage where I thought the WSP file was ready to go. It's recognised by WinRAR, opening it up in there shows the expected dll's.

But there was something missing...

feature.xml

Attempting to deploy the WSP threw:
Failed to find the XML file at location '12\Template\Features\IL.SharePoint.Workflows\feature.xml'

This TechNet page on InstallFeature clears up the exact cause being a missing feature.xml. It also cleared up that the 'root' of the WSP is equivalent to 12\Template\Features\ a location in the "12 hive".

Opening up the WSP, sure enough there was no sign of feature.xml, so it was time to head back into WSPbuilder.exe -help where I found...

-12path

The default for the 12path is the current directory, here again, since we're not running from the project directory, the current directory isn't much good, so I needed to set the 12 path.

Setting the 12path to the location of the feature.xml got it included in the WSP, but the manifest.xml included it in the RootFiles element. Based on our manually built WSP, we saw we needed it to be in the FeatureManifests element.

After some searching I looked again at the before build image on the WSPBuilder CodePlex site. Turns out this is rather useful once you know what you're looking at. There you'll see the path WSPDemo/12/Template/FEATURES/WSPDemo/; after seeing that, it dawned on me that I had actually read something about "putting the contents of your 12 hive into the project folder" - so that's what they meant.

So finally the files were included in the WSP in the right location:

-DeploymentTarget GAC

Because of the way our solution is set up we need to target the GAC, we were getting:
<Assembly Location="IL.SharePoint.Workflows.dll" DeploymentTarget="WebApplication" />
in the manifest.xml. Changing the DeploymentTarget from the default of Auto to GACyielded the required:
<Assembly Location="IL.SharePoint.Workflows.dll" DeploymentTarget="GlobalAssemblyCache" />

-BuildCAS False

The default for this is True, with it on, the manifest file was spammed full of CAS information and trying to deploy gave the error:

The solution "IL.SharePoint.Workflows.wsp" needs to add Code Access Security policies. If you fully trust this solution, use the -allowCasPolicies parameter to deploy.
True, using -allowCasPolicies did remove the error, but adding -BuildCAS False cleaned up the manifest file and removed the need for this switch to stsadm.

Revised WSPBuilder command line

All this meant the following amended Exec command in the tfsbuild.proj.

    <Exec Command='"C:\Program Files\WSPTools\WSPBuilderExtensions\WSPBuilder"

          -DeploymentTarget GAC

          -BuildCAS false

          -SolutionPath "$(OutDir)"

          -BinPath "$(OutDir)"

          -OutputPath "$(WspDir)"

          -12Path "$(OutDir)12"

          -WSPName IL.SharePoint.Workflows.wsp'

          />

Posted on Tuesday, May 26, 2009 by Unknown

No comments

14 May 2009

We needed to build a Sharepoint WSP file in TFS as part of our continuous integration process. Already using WSPBuilder interactively we just needed to get it into the team build and copied to the staging location.

WSPBuilder

Brian Farnhill discusses the process of building a WSP in TFS by first including it in the project file (summary by Alex Degaston). This pointed me in the right direction, but I really just wanted to build the WSP in the team build after check-in.

We just copied the basics from Brian's post, and hoped it would work, and amazingly, we had a WSP file. Frustratingly, the WSPBuilder will happily create a WSP file even if it finds nothing to put in it.

After some experimenting on the command line, it turns out you need to specify both SolutionPath and BinPath to get WSPBuilder to build successfully, using the team build property OutDir worked for this. Including the feature.xml and workflow.xml as content in the root of the project ensures they're in the output folder.

The default name for the WSP is the folder name, so to override this, use WSPName.

File drop

The easiest way to get the files out was to override BeforeDropBuild and put them in the OutDir. I'm using xcopy for this as it's easier to test on the command line (also, using the copy task would require (I think) further nesting the copy operation because of the order of item expansion). They're then ready for the team build to perform the drop to the staging location.

Finally

All this boils down to this two liner added to the TFSBuild.proj:

  <Target Name ="BeforeDropBuild" >

    <PropertyGroup>

      <WspDir>$(SolutionRoot)\Code\IL.SharePoint.Workflows\DeploymentFiles</WspDir>

    </PropertyGroup>

    <Exec Command='"C:\Program Files\WSPTools\WSPBuilderExtensions\WSPBuilder"

          -SolutionPath "$(OutDir)"

          -BinPath "$(OutDir)"

          -OutputPath "$(WspDir)"

          -WSPName IL.SharePoint.Workflows.wsp'

          />

    <Exec Command='xcopy /E /Y /I

          "$(WspDir)"

          "$(OutDir)DeploymentFiles"'

          />

  </Target>

Posted on Thursday, May 14, 2009 by Unknown

No comments

12 May 2009

Trawling through Microsoft.TeamFoundation.Build I found the flag for IncrementalGet. Not getting full sources every time has cut 40 seconds out of every build. This is particularly useful when debugging a build script.

Buck Hodges discusses IncrementalGet and IncrementalBuild and links to Martin Woodward's 30 Useful Team Build Properties. Not sure I'm ready for IncrementalBuild yet, I like having shiny new dll's.

This is what I added to my root level PropertyGroup just before DropLocation:

    <!-- INCREMENTAL GET

      Setting this flag will set:

      CleanCompilationOutputOnly: true

      SkipInitializeWorkspace: true

      ForceGet: false

      (Microsoft.TeamFoundation.Build Line:379)

    -->

    <IncrementalGet>true</IncrementalGet>

Posted on Tuesday, May 12, 2009 by Unknown

No comments

03 April 2009

Yay, today I finished the last stage of Bloons Tower Denfense III on hard. Hopefully this will cure the compulsion. Oh look, meeblings...

Posted on Friday, April 03, 2009 by Unknown

1 comment