0

I'm attempting to transform crossdomain.xml for different environments, just like regular web.config files. I've tried using SlowCheetah add-in for visual studio, but it doesn't play well with web applications. It kept publishing transform files along with the transformed file, which i didn't want. Moreover, it did that for web.config transformation as well.

My other thought was to rename the file and all transforms to crossdomain.$(Configuration).config in hopes that VS would pick it up and transform it and then rename it somewhere in the build process to crossdomain.xml. But VS wouldn't transform it at all. Here is what my transforms look like at the moment.

crossdomain.config

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain- policy.dtd">
<cross-domain-policy>
   <allow-access-from domain="*" secure="false" />
</cross-domain-policy>

crossdomain.stage.config

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
   <allow-access-from domain="*.foo.com" secure="true" xdt:Transform="Replace" />
</cross-domain-policy>

Does anybody have any suggestions?

UPDATE The more i spend time on this, the more i realize that deployments in .NET are a complete nightmare. Still trying to figure this out. Looks like VS publishing feature does some sort of half-assed deployment. It calls up MSBuild to gather files to deploy and then deploys it manually outside of MSBuild. So, there is no way to get the deployment path to do the transform. I'd have to stub it into MSBuild as a parameter.

Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178
Sergey Akopov
  • 1,130
  • 1
  • 11
  • 25
  • 1
    The issue w SlowCheetah publishing transforms is a bug. I'll fix it in the next version. In the mean time you can set Build Action to None so they don't get published. – Sayed Ibrahim Hashimi Apr 07 '12 at 23:59
  • Awesome! Thanks for the update. I'll keep an eye out for the update. – Sergey Akopov Apr 08 '12 at 04:34
  • Dude, you are spot on with Microsoft cobbling together a joke of a publishing solution. It has always been that way and I dont expect it to ever get better. Microsoft even has a group where they demo how to take advantage of TFS and they basically re-engineer the whole deployment process with custom stuff not integrated into Visual Studio. It's a joke. – John Zabroski Jan 04 '17 at 21:39

1 Answers1

0

Hate to be answering my own question, but the following link helped get this straightened out:

https://stackoverflow.com/a/5381408/546709

<Target Name="TransformOtherConfigs" AfterTargets="CollectWebConfigsToTransform">
<ItemGroup>
<WebConfigsToTransform Include="@(FilesForPackagingFromProject)"
                       Condition="'%(FilesForPackagingFromProject.Extension)'=='.config'"
                       Exclude="*.$(Configuration).config;$(ProjectConfigFileName)">
    <TransformFile>%(RelativeDir)%(Filename).$(Configuration).config</TransformFile>
    <TransformOriginalFile>$(TransformWebConfigIntermediateLocation)\original\%(DestinationRelativePath)</TransformOriginalFile>
    <TransformOutputFile>$(TransformWebConfigIntermediateLocation)\transformed\%(DestinationRelativePath)</TransformOutputFile>
    <TransformScope>$([System.IO.Path]::GetFullPath($(_PackageTempDir)\%(DestinationRelativePath)))</TransformScope>
</WebConfigsToTransform>
   <WebConfigsToTransformOuputs Include="@(WebConfigsToTransform->'%     (TransformOutputFile)')" />
</ItemGroup>
</Target>
Community
  • 1
  • 1
Sergey Akopov
  • 1,130
  • 1
  • 11
  • 25