从命令行运行 web.config 转换
再会!
我希望能够使用 VS2010 发布对话框和从命令行构建 ASP.NET MVC 2 项目。
对于命令行,我得到以下工作:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SolutionFolder\MyProject.csproj /p:Configuration=Release;DeployOnBuild=True;PackageAsSingleFile=False;outdir=c:\_OutputFolder\
我遇到的唯一问题是 Web.config 转换未应用(但添加到 WebDeploy 包中)。我不使用 WebDeploy。有什么方法可以应用 Web.config 转换吗?
谢谢!
Good day!
I want to have ability to build ASP.NET MVC 2 project using VS2010 Publish dialog and from command-line.
For command-line I get the following to work:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SolutionFolder\MyProject.csproj /p:Configuration=Release;DeployOnBuild=True;PackageAsSingleFile=False;outdir=c:\_OutputFolder\
The only problem I have that Web.config transformation are not applied (but added to WebDeploy package). I don't use WebDeploy. Is there any way to apply Web.config transformations?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还可以尝试使用 XDT 转换工具:
http://ctt.codeplex.com 已移至 Github
https://github.com/greenfinch/ctt
我正在使用它,而不是搞乱晦涩的 msbuild目标。
You can also try using the XDT Transformation Tool:
http://ctt.codeplex.com was moved to Github
https://github.com/greenfinch/ctt
I'm using this instead of messing with obscure msbuild targets.
这是另一种方法,它使用 msbuild 转换 Web.config 文件:
http://sedodream。 com/2010/04/26/ConfigTransformationsOutsideOfWebAppBuilds.aspx
在我的测试中,结果更好。基本上,您创建一个项目文件仅执行 TransformXML 任务:
保存项目文件,然后应用转换,运行以下命令:
其中 trans.proj 是项目文件的名称,Demo 是任务目标的名称。
Here is another approach, which uses msbuild to transform Web.config file:
http://sedodream.com/2010/04/26/ConfigTransformationsOutsideOfWebAppBuilds.aspx
In my tests the results were better. Basically, you create a project file to perform only a TransformXML task:
Save the project file and then apply the transformation, running the following command:
Where trans.proj is the name of the project file and Demo is the name of task target.
我认为值得一提的是,您还可以将 Visual Studio 使用的 DLL 与 PowerShell 一起使用:
Microsoft.Web.XmlTransform.dll
PowerShell 脚本,请参阅:Web.Config 在 Microsoft MSBuild 之外进行转换?
加载 DLL 而不是四处复制,我确实喜欢这样(所以你知道在哪里可以找到这个 DLL,至少在我的工作场景中我们必须查找这些位置):
I think it's worth to mention that you can also use with PowerShell the DLL that Visual Studio is using:
Microsoft.Web.XmlTransform.dll
PowerShell script, see: Web.Config transforms outside of Microsoft MSBuild?
To load the DLL instead of copying around, I do like this (so you see where to find this DLL, at least in my scenario at work we had to look-up these locations):