我的解决方案有 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 和“自定义”构建配置网站构建解决方案时,根本不会编译。
但是,当我在解决方案文件中手动添加以下行时,一切都按预期工作。:
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 开发团队提交一个错误?
如果其他人有同样的问题并有任何解决方法的建议?谢谢!