Webbuild被msbuild重命名 [英] Web.config is being renamed by msbuild

查看:178
本文介绍了Webbuild被msbuild重命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS 2013构建Web服务.构建后,Web.config文件将重命名为"{projectname} .dll.config".

I am using VS 2013 to build a webservice. When it is built, the Web.config file is being renamed "{projectname}.dll.config".

有一个步骤_CopyAppConfigFile,在该步骤中,它被重命名,显示在输出"窗口中.我可以通过将web.config设置为始终复制来解决此问题,这将产生两个文件,即web.config和x.dll.config,我可以使用它们,但是如果有人的话,我想完全避免使用它知道怎么做.

There is a step, _CopyAppConfigFile where it gets renamed, showing in the Output window. I can work around this, by setting the web.config to be copied always, this results in two files, web.config and x.dll.config, which I can live with, but I'd like to avoid it completely if anyone knows how.

看起来这是位于以下位置的MSBuild文件的结果:

Looks like this is a result of a MSBuild file, located at:

C:\Program Files\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets

推荐答案

我可以在C#ASP.NET MVC项目的Visual Studio 2013的默认安装中重新创建它.我注意到了这一点,因为我开始过渡到Visual Studio 2013,但是我们的构建服务器仍在Visual Studio 2012上.我的提交之一之后,我们的安装项目失败了,因为构建服务器上没有生成我在计算机上收获的多余配置文件.

I can recreate this in a default install of Visual Studio 2013 in a C# ASP.NET MVC project. I noticed it because I am starting to transition to Visual Studio 2013, but our build server is still on Visual Studio 2012; our setup project was failing after one of my commits because the superfluous config file that I had harvested on my machine was not being generated on the build server.

这似乎是以前版本的MSBuild 4.0/Visual Studio 2012和新版本的MSBuild 12.0/Visual Studio 2013的工作方式之间的差异.

This appears to be a discrepancy between the way things worked in the previous version of MSBuild 4.0 / Visual Studio 2012 and the new version MSBuild 12.0 / Visual Studio 2013.

在Visual Studio 2013中,将$(ProjectConfigFileName)属性初始化为Web.config [1],然后将其复制到$(AppConfig) [2],这将导致_CopyAppConfigFile运行[3],从而导致不必要的配置文件被命名并复制到bin目录.

In Visual Studio 2013, the $(ProjectConfigFileName) property is initialized to Web.config [1], which is copied to $(AppConfig) [2], which causes _CopyAppConfigFile to run [3], resulting in an unnecessary config file being named and copied over to the bin directory.

在Visual Studio 2012中,该过程与之类似,只是其Microsoft.WebApplication.targets版本缺少2013版中的该部分:

In Visual Studio 2012, the process is similar, except that its version of Microsoft.WebApplication.targets is missing this part that's in the 2013 version:

  <!-- Instruct ResolveAssemblyReferences in MS.Common.targets to generate suggested binding redirects. -->
  <PropertyGroup>
        <AutoUnifyAssemblyReferences>false</AutoUnifyAssemblyReferences>
        <AppConfig Condition="'$(AppConfig)' == '' And Exists('$(ProjectConfigFileName)')">$(ProjectConfigFileName)</AppConfig>
  </PropertyGroup>

关键是该AppConfig行.由于2012版中缺少AppConfig引用,因此_CopyAppConfigFile不能在Visual Studio 2012下运行,从而导致预期的行为(即,未复制文件).

The key is that AppConfig line. Since that AppConfig reference is missing in the 2012 version, then _CopyAppConfigFile doesn't run under Visual Studio 2012, resulting in the intended behavior (i.e., the file is not copied).

在Visual Studio 2013中,看起来他们添加了这一行,以便构建过程可以通过在Visual Studio的错误"列表中双击它们来为您修复绑定重定向.当Microsoft添加此功能时,似乎没有人注意到它导致生成了一个额外的配置文件并将其复制到输出文件夹.因此在我看来,这似乎是Visual Studio 2013的新生成过程中的错误(但由于配置文件是多余的,所以几乎没有害处).因为它与我的生成服务器上的Visual Studio 2012生成过程冲突,我增加了一个额外的构建后步骤来删除无关的文件:

In Visual Studio 2013, it looks like they added this line so that the build process could offer to fix up binding redirects for you by double-clicking on them in the Errors list in Visual Studio. When Microsoft added this, it seems no one noticed that it resulted in an extra config file being generated and copied to the output folder. So it seems to me as if it is a bug (but a mostly harmless one, since the config file is superfluous) in the new build process in Visual Studio 2013. Since it was conflicting with the Visual Studio 2012 build process on my build server, I added an extra post-build step to blow away the extraneous file:

  <Target Name="AfterBuild">
        <Delete ContinueOnError="true" Files="$(TargetPath).config" />
  </Target>

然后您会更好地知道这与您的特定项目或系统设置无关,这只是Visual Studio 2013现在执行操作的方式.

And then you can feel better knowing that it's not a problem with your particular project or system setup, it's just the way Visual Studio 2013 does things now.

上面引用的文件位置:

[1] C:\ Program Files(x86)\ MSBuild \ Microsoft \ VisualStudio \ v12.0 \ Web \ Microsoft.Web.Publishing.targets

[1] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets

[2] C:\ Program Files(x86)\ MSBuild \ Microsoft \ VisualStudio \ v12.0 \ WebApplications \ Microsoft.WebApplication.targets

[2] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets

[3] C:\ Program Files(x86)\ MSBuild \ 12.0 \ Bin \ Microsoft.Common.CurrentVersion.targets

[3] C:\Program Files (x86)\MSBuild\12.0\Bin\Microsoft.Common.CurrentVersion.targets

这篇关于Webbuild被msbuild重命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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