title: Publish to Service Fabric Cluster fails because of Test-ServiceFabricClusterConnection
body: <p>I am using the Deploy-FabricApplication.ps1 script that is generated when you create a Service Fabric project to deploy my application.</p>
  
  <p>When deploying to a Service Fabric cluster I can deploy locally if I first connect to a local cluster using <code>Connect-ServiceFabricCluster</code>. However, my build server does not run a local cluster instance so I am unable to first connect to a local instance. When I connect with <code>Connect-ServiceFabricCluster @ClusterConnectionParameters</code> I get data back on the connection that it was successful. When it gets to the publish and runs the Test-ServiceFabricClusterConnection command I get the following error.</p>
  
  <pre><code>WARNING: Unable to Verify connection to Service Fabric cluster.
  Test-ServiceFabricClusterConnection : Cluster connection instance is null
  At C:\ProgramFiles\MicrosoftSDKs\ServiceFabric\Tools\PSModule\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1:129 char:16
  +         [void](Test-ServiceFabricClusterConnection)
  +                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ResourceUnavailable: (:) [Test-ServiceFabricClusterConnection], NullReferenceException
      + FullyQualifiedErrorId : GetClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.TestClusterConnection
  </code></pre>
  
  <p>I have tried removing Test-ServiceFabricClusterConnection from the Publish-NewServiceFabricApplication.ps1 module and I get a different set of errors. No matter what I have tried to this point, if I first connect to a cluster it works but not if I connect via the powershell script.</p>
  
  <p>Update! Solved
  Solved this using dot sourcing: <a href="https://stackoverflow.com/questions/35711540/how-do-i-deploy-service-fabric-application-from-vsts-release-pipeline">How do I deploy service fabric application from VSTS release pipeline?</a></p>