How to change csdef defined in cspkg

For deployment in different azure environments, I modify csdef as part of the compilation step to change host headers. This requires creating cspkg once for each environment instead of reusing cspkg and specifying different configurations for deployment.

I would like to change the cspf cspkg file instead after creating it without recompiling. Is this possible, and if so, how?

+3
source share
3 answers

I did something similar to what you need to distinguish between test and live environments. First of all, you need to create a new .csdef file that you want to use for your alternative settings. This should be a complete file, as we are just going to replace it with the original one. Now we need to add this to the cloud project. Right-click on the cloud project and select the offload project. Right-click on it again and select "Edit" [Project Name]. There's a section that looks something like this:

<ItemGroup>
    <ServiceConfiguration Include="ServiceConfiguration.Test.cscfg" />
    <ServiceDefinition Include="ServiceDefinition.csdef" />
    <ServiceConfiguration Include="ServiceConfiguration.cscfg" />
</ItemGroup>

Add a new ServiceDefinition element that points to your newly created file. Now find the following line:

<Import Project="$(CloudExtensionsDir)Microsoft.WindowsAzure.targets" />

, TargeProfile, , , , .csdef

<Target Name="AfterResolveServiceModel">
    <!-- This should be run after it has figured out which definition file to use
        but before it done anything with it.  This is all a bit hard coded, but
        basically it should remove everything from the SourceServiceDefinition
        item and replace it with the one we want if this is a build for test-->
    <ItemGroup>
      <!-- This is an interesting way of saying remove everything that is in me from me-->
      <SourceServiceDefinition Remove="@(SourceServiceDefinition)" />
      <TargetServiceDefinition Remove="@(TargetServiceDefinition)" />
    </ItemGroup>
    <ItemGroup Condition="'$(TargetProfile)' == 'Test'">
      <SourceServiceDefinition Include="ServiceDefinition.Test.csdef" />
    </ItemGroup>
    <ItemGroup Condition="'$(TargetProfile)' != 'Test'">
      <SourceServiceDefinition Include="ServiceDefinition.csdef" />
    </ItemGroup>
    <ItemGroup>
      <TargetServiceDefinition Include="@(SourceServiceDefinition->'%(RecursiveDirectory)%(Filename).build%(Extension)')" />
    </ItemGroup>
    <Message Text="Source Service Definition Changed To Be: @(SourceServiceDefinition)" />
  </Target>

, " ". , , , .csdef. , .csdef, , , .

+5

CSDEF, , CSPACK, :

  • , CSDEF/CSCFG CSX, Windows Azure
  • CSDEF .
  • Windows Azure SDK CS *.
  • CSPACK CSDEF CSPKG, :

cspack <ProjectName>\ServiceDefinitionOne.csdef /out:ProjectNameSame.csx /out:ProjectOne.cspkg /_AddMoreParams

cspack <ProjectName>\ServiceDefinitionTwo.csdef /out:ProjectNameSame.csx /out:ProjectTwo.cspkg /_AddMoreParams

CSPACK: http://msdn.microsoft.com/en-us/library/windowsazure/gg432988.aspx

+3

, .cspkg . , , , , .cspkg - zip , .

, , ? , VM ( , .csdef), , :

  • Windows Azure (.csproj) . , , , Visual Studio . , .
  • . web.config.

.csproj. , ., .;) , .

0

All Articles