Sunday, 6 December 2015

Disable multiple checkout in TFS

Case
I tried disabling the TFS multiple checkout for an SSIS project, but my collegue and me can still check out the same SSIS package at the same time causing all kinds of issues when checking in the changed package. How can I disable multiple checkout?
Disable multiple checkout in TFS

















Solution
You need to check your workspaces. If one of you is still using a local workspace then you can still checkout the same package multiple times.

Go to the Source Control Explorer in Visual Studio. You can find the link in the Team Explorer pane. Then (1) open the Workspace selectbox and choose Workspaces... In the Manage Workspaces window click (2) on the Edit... button and then (3) on the Advanced >> button.
Edit Workspace














In the advanced option change the location from Local to Server and click on OK and one more time in the next window.
Set workspace location to server




















If you both use the workspace on the server then you will get an message that the SSIS package is checked out by user xxx.
Package checked out by colleague Menno














Now you only need to remember to don't keep the project or solution checked out otherwise no one else can add (, delete or rename) projects/packages/connection managers/etc. When adding a new package the project will be checked out. To prevent long check outs, you should first give the new/empty package its correct name and then check-in everything (the project and the new/empty package). Only then you can start building the new package!
Also see MSND for more information about local and server workspaces.

Monday, 30 November 2015

BIML force creating connection managers

Case
If you declare a connection manager in BIML, but don't use it in one of the tasks or transformations, it won't be created. Can you force BIML to create the connection managers nevertheless?


No connection managers were created
















Solution
In some cases you want to override this feature and just create the connection managers. For example when using Custom Tasks/Transformations where BIML doesn't recognize a connection manager attribute.



To force BIML to create the connection managers you need to add a second <Connections> tag, but this time within the package tag. And within this tag you can add <Connection> tags with a ConnectionName attribute. As a value you need to need to supply the name of the connection manager that you created in the first <Connections> tag.
Force creating connection managers
















<Biml xmlns="http://schemas.varigence.com/biml.xsd">
  <Connections>
    <AdoNetConnection ConnectionString="Data Source=.;Initial Catalog=tempdb;Integrated Security=True;"
        Provider="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        Name="myStage"
        CreateInProject="true"
        />
    <FileConnection FileUsageType="ExistingFolder"
        FilePath="d:\"
        Name="myFolder"
        CreateInProject="false"
        />
  </Connections>

  <Packages>
    <Package Name="myPackage" ProtectionLevel="DontSaveSensitive">
      <Tasks>
        <Container Name="myContainer">
          
        </Container>
      </Tasks>
      <Connections>
        <!--  Force creating connection managers  -->
        <Connection ConnectionName="myStage" />
        <Connection ConnectionName="myFolder" />
      </Connections>
    </Package>
  </Packages>
</Biml>


You can even determine the guid of each connection manager.
<Connections>
  <!--  Force creating connection managers  -->
  <Connection ConnectionName="myStage"
        Id="{365878DA-0DE4-4F93-825D-D8985E2765FA}"/>
  <Connection ConnectionName="myFolder"
        Id="{365878DA-0DE4-4F93-825D-D8985E2765FB}"/>
</Connections>


And if you need the same GUID in multiple places within your script, but you want a random GUID, then you can add a string variable and fill it with a random GUID. Then you can use that variable in multiple places.
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
  <Connections>
    <AdoNetConnection ConnectionString="Data Source=.;Initial Catalog=tempdb;Integrated Security=True;"
            Provider="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            Name="myStage"
            CreateInProject="true"
        />
    <FileConnection FileUsageType="ExistingFolder"
            FilePath="d:\"
            Name="myFolder"
            CreateInProject="false"
        />
  </Connections>
  
  <#
    // Create Random Guid but use it in multiple places
    string myGuid = System.Guid.NewGuid().ToString();
  #>

    <Packages>
    <Package Name="myPackage" ProtectionLevel="DontSaveSensitive">
      <Tasks>
        <Container Name="myContainer">
          
        </Container>
      </Tasks>
      <Connections>
        <!--  Force creating connection managers    -->
        <Connection ConnectionName="myStage"
              Id="<#=myGuid#>"/>
        <Connection ConnectionName="myFolder"
              Id="{365878DA-0DE4-4F93-825D-D8985E2765FB}"/>
      </Connections>
    </Package>
  </Packages>
</Biml>
Related Posts Plugin for WordPress, Blogger...