为什么 Visual Studio 不在解决方案文件中为与标准(发布/调试)不同的配置添加 AspNetCompiler 设置?

发布于 2024-09-28 10:47:29 字数 1651 浏览 2 评论 0原文

我的解决方案有 3 种构建配置:发布、调试和自定义。我还有WebSite(是的,不是WebApplication)项目类型。默认情况下,当您创建网站时,VisualStudio 2008 会向解决方案文件添加以下部分:

Debug.AspNetCompiler.VirtualPath = "/MyWebSite"
Debug.AspNetCompiler.PhysicalPath = "MyWebSite\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\MyWebSite\"
Debug.AspNetCompiler.Updateable = "false"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/MyWebSite"
Release.AspNetCompiler.PhysicalPath = "MyWebSite\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\MyWebSite\"
Release.AspNetCompiler.Updateable = "false"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
SlnRelativePath = "\MyWebSite\"

MSBuild 使用此配置来预编译/发布网站。正如您所看到的,这里没有我的“自定义”构建配置的配置,仅适用于“发布”“调试”。因此,当我尝试使用 MSBuild 和“自定义”构建配置 WebSite 构建解决方案时,根本无法编译。

但是,当我在解决方案文件中手动添加以下行时,一切都会按预期进行。 :

Custom.AspNetCompiler.VirtualPath = "/MyWebSite"
Custom.AspNetCompiler.PhysicalPath = "MyWebSIte\"
Custom.AspNetCompiler.TargetPath = "PrecompiledWeb\MyWebSite\"
Custom.AspNetCompiler.Updateable = "false"
Custom.AspNetCompiler.ForceOverwrite = "true"
Custom.AspNetCompiler.FixedNames = "false"
Custom.AspNetCompiler.Debug = "True"

我认为这是 VisualStudio 2008 中的一个错误(我在 2010 年检查过这一点)。问题是,当 VisualStudio 2008 修改解决方案文件时(例如,在添加新项目的情况下),我手动添加的行将被删除。也许我应该向 Microsoft VS 开发团队提交一个错误?

如果其他人也遇到同样的问题并有任何建议如何解决?谢谢!

I have 3 build configurations for my solution: Release, Debug, and Custom. Also I have WebSite (yes, not a WebApplication) project type. By default, when you create WebSite VisualStudio 2008 adds to the solution file following sections:

Debug.AspNetCompiler.VirtualPath = "/MyWebSite"
Debug.AspNetCompiler.PhysicalPath = "MyWebSite\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\MyWebSite\"
Debug.AspNetCompiler.Updateable = "false"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/MyWebSite"
Release.AspNetCompiler.PhysicalPath = "MyWebSite\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\MyWebSite\"
Release.AspNetCompiler.Updateable = "false"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
SlnRelativePath = "\MyWebSite\"

This configuration is used by MSBuild to precompile/publish WebSite. As you can see here is no configuration for my "Custom" build configuration, only for "Release" and "Debug". So when I am trying to build solution with MSBuild and with "Custom" build configuration WebSite simply don't get compiled.

But, when I manually add following lines in solution file everything works as expected. :

Custom.AspNetCompiler.VirtualPath = "/MyWebSite"
Custom.AspNetCompiler.PhysicalPath = "MyWebSIte\"
Custom.AspNetCompiler.TargetPath = "PrecompiledWeb\MyWebSite\"
Custom.AspNetCompiler.Updateable = "false"
Custom.AspNetCompiler.ForceOverwrite = "true"
Custom.AspNetCompiler.FixedNames = "false"
Custom.AspNetCompiler.Debug = "True"

I think that this is a bug in VisualStudio 2008 (I've checked this in 2010). The problem is that when VisualStudio 2008 will modify solution file (e.g. in case of adding a new project) my manually added lines will be removed. Maybe I should submit a bug somewhere to Microsoft VS development team?

If anyone else had the same problem and had any suggestions how to solve it? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光无声 2024-10-05 10:47:29

您可以通过“配置管理器”对话框(在“生成”>“配置管理器”菜单项下)将“自定义”配置添加到您的项目中吗?您手动添加的部分可能不完整,或者解决方案文件中还有 VisualStudio 无法识别的其他部分预计也会发现修改。

Can you add the "Custom" configuration to your project via the Configuration Manager dialog (under the Build > Configuration Manager menu item?) It's possible that your manually-added section is incomplete, or there is another section in the solution file that VisualStudio expects to find modified as well.

简单爱 2024-10-05 10:47:29

没有官方的方法可以做到这一点。

There is no official way of doing this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文