在asp.net web应用程序发布转化为crossdomain.xml [英] Transforming crossdomain.xml on publish in asp.net web application

查看:192
本文介绍了在asp.net web应用程序发布转化为crossdomain.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变的crossdomain.xml针对不同的环境,就像普通的web.config文件。我已经使用SlowCheetah附加为Visual Studio试过,但它不会与Web应用程序发挥好。它不停地与发布在转化文件,我不想一起转换文件。而且,它确实对于web.config文件转化为好。

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.

我的另一个想法是重命名的文件和所有变换到跨域。在希望将VS把它捡起来,改造它,然后在构建过程中加入crossdomain.xml某处将其重命名$(配置)的.config。不过VS不会改变它。这里是我的变换样子的时刻。

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?

更新
我越花时间在这,我越来越意识到,在.NET的开发上是一个完整的噩梦。仍在试图弄清楚这一点。貌似VS发布功能做一些半称职的部署。它调出的MSBuild收集文件部署,然后手动部署它的MSBuild之外。那么,有没有办法让做变换的部署路径。我不得不把它的存根的MSBuild作为参数。

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.

推荐答案

讨厌被回答我的问题,但下面的链接帮助得到这个理顺:

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

http://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>

这篇关于在asp.net web应用程序发布转化为crossdomain.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆