构建 Web 部署项目时找不到文件

发布于 2024-11-07 15:30:29 字数 2173 浏览 5 评论 0原文

我有一个 Web 部署项目,用于构建和压缩 Web 应用程序项目。我在构建WDP时遇到很多错误,如下所示:

错误 73 文件“/Foo.csproj/Properties/Administration/Modules/ACL.ascx”不存在。 /Foo.csproj/Properties/Administration/ACL.aspx

错误 74 未知的服务器标记“foo:ACL”。 /Foo.csproj/Properties/Administration/ACL.aspx

这些错误来自 Web 部署项目,而不是 WAP。 错误总是遵循相同的模式,首先是查找 .ascx 时出现错误,然后出现关联错误,表示与先前的 ascx 相关的服务器标记未知(这显然是有道理的)。

ascx 或 aspx 中没有错误或警告。

这些控件是使用 <%@ Register %> 标记注册的(而不是在 web.config 中注册)

什么可能导致这种症状?


< strong>更新

错误来自使用以下命令运行的aspnet_compiler.exe

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v "/Foo.csproj" -p "C:\Projects\Foo\Foo" -u -f -d obj\Staging \TempBuildDir

和产生以下错误

预编译 ASP.NET 应用程序的实用程序
版权所有 (C) 微软公司。版权所有。 /Foo.csproj/Properties/Administration/ACL.aspx(5):错误 ASPPARSE:文件“/Foo.csproj/Properties/Administration/Modules/ACL.ascx”不存在。
/Foo.csproj/Properties/Administration/ACL.aspx(7): 错误 ASPPARSE: 未知的服务器标记“foo:ACL”。

在 Foo.csproj 中,ACL.aspx 被声明为

<Content Include="Administration\ACL.aspx" />

<!-- Snip -->

<Compile Include="Administration\ACL.aspx.cs">
  <DependentUpon>ACL.aspx</DependentUpon>
  <SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Administration\ACL.aspx.designer.cs">
  <DependentUpon>ACL.aspx</DependentUpon>
</Compile>

ACL.ascx,因为

<Content Include="Administration\Modules\ACL.ascx" />

<!-- Snip -->

<Compile Include="Administration\Modules\ACL.ascx.cs">
  <DependentUpon>ACL.ascx</DependentUpon>
  <SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Administration\Modules\ACL.ascx.designer.cs">
  <DependentUpon>ACL.ascx</DependentUpon>
</Compile>

我无法理解路径的 /Properties/ 元素来自错误中的路径!它不在项目文件中,也没有被提供给 aspnet_compiler.exe

解决方案文件和项目文件与工作解决方案相同(项目名称除外)。

I've got a web deployment project that builds and zips a web application project. I am getting a lot of errors when I build the WDP, as follows:

Error 73 The file '/Foo.csproj/Properties/Administration/Modules/ACL.ascx' does not exist. /Foo.csproj/Properties/Administration/ACL.aspx

Error 74 Unknown server tag 'foo:ACL'. /Foo.csproj/Properties/Administration/ACL.aspx

These errors are coming from the Web Deployment Project, not the WAP.
The errors always follow the same pattern, first there is an error finding the .ascx and then an associated error saying the server tag related to the previous ascx is unknown (this obviously makes sense).

There are no errors or warnings in the ascx or aspx.

The controls are registered using a <%@ Register %> tag (as opposed to being registered in the web.config)

What could be causing such a symptom?


UPDATE

The errors are coming from aspnet_compiler.exe which is run with the following command:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v "/Foo.csproj" -p "C:\Projects\Foo\Foo" -u -f -d obj\Staging\TempBuildDir

and produces the following errors

Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.
/Foo.csproj/Properties/Administration/ACL.aspx(5): error ASPPARSE: The file '/Foo.csproj/Properties/Administration/Modules/ACL.ascx' does not exist.
/Foo.csproj/Properties/Administration/ACL.aspx(7): error ASPPARSE: Unknown server tag 'foo:ACL'.

in Foo.csproj ACL.aspx is declared as

<Content Include="Administration\ACL.aspx" />

<!-- Snip -->

<Compile Include="Administration\ACL.aspx.cs">
  <DependentUpon>ACL.aspx</DependentUpon>
  <SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Administration\ACL.aspx.designer.cs">
  <DependentUpon>ACL.aspx</DependentUpon>
</Compile>

and ACL.ascx as

<Content Include="Administration\Modules\ACL.ascx" />

<!-- Snip -->

<Compile Include="Administration\Modules\ACL.ascx.cs">
  <DependentUpon>ACL.ascx</DependentUpon>
  <SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Administration\Modules\ACL.ascx.designer.cs">
  <DependentUpon>ACL.ascx</DependentUpon>
</Compile>

I can't understand where the /Properties/ element of the paths is coming from in the paths in the error ! It's not in project file and it's not being fed to aspnet_compiler.exe.

The solution file and project files are identical (apart from project names) to a working solution.

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

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

发布评论

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

评论(4

听,心雨的声音 2024-11-14 15:30:29

我刚刚在我办公桌上的一个项目中遇到了同样的情况,这是我的解决方案:

//doesn't work
<%@ Control Language="C#" 
    AutoEventWireup="true" 
    Inherits="Controls_CatalogCustomerORW"
    CodeFile="CatalogCustomerORW.ascx.cs" %>

//does work
<%@ Control Language="C#" 
    AutoEventWireup="true"
    Inherits="Controls_CatalogCustomer" 
    Codebehind="CatalogCustomer.ascx.cs" %>

错误似乎是非常微妙的 CodeFileCodeBehind

I just came across this same situation in a project at my desk, and here was my solution:

//doesn't work
<%@ Control Language="C#" 
    AutoEventWireup="true" 
    Inherits="Controls_CatalogCustomerORW"
    CodeFile="CatalogCustomerORW.ascx.cs" %>

//does work
<%@ Control Language="C#" 
    AutoEventWireup="true"
    Inherits="Controls_CatalogCustomer" 
    Codebehind="CatalogCustomer.ascx.cs" %>

The error appears to be the ever subtle CodeFile vs CodeBehind

晨曦÷微暖 2024-11-14 15:30:29

当文件的“构建操作”设置为 None 而不是 时,我看到了与此类似的内容(我的记忆确实有点模糊!)内容。要查看这是否是问题所在:

  1. 在解决方案资源管理器中右键单击有问题的文件,然后选择属性
  2. 查看该文件的“生成操作”,如果它显示 将其更正为内容

另一种可能性是您的 .csproj 中出现了“错误”,因为 ACL.ascx 的路径看起来非常奇怪。它真的应该在 /Foo.csproj/Properties/ 下吗?如果我的第一个建议没有帮助,我建议尝试以下操作:

  1. 在解决方案资源管理器中右键单击 Foo.csproj 并选择 Unload Project
  2. 一旦完成卸载,在解决方案资源管理器中右键单击 Foo.csproj(不可用) 并选择编辑 Foo.csproj
  3. 搜索 ACL.ascx 并比较 XML 标记对于该文件到另一个不会生成错误的“好”文件,可能存在导致错误的细微差别

I've seen something similar to this (my recollection is admittedly a bit hazy!) when the "Build Action" for the file is set to None rather than Content. To see if this is the issue:

  1. Right-click on the file that's at issue, in Solution Explorer, and choose Properties
  2. Look at the "Build Action" for the file, if it says None correct it to Content.

The other possibility is that something has gone "wrong" in your .csproj as the path to ACL.ascx looks decidedly odd. Should it really be under /Foo.csproj/Properties/? If my first suggestion isn't helpful, I'd suggest trying the following:

  1. Right-click on Foo.csproj in Solution Explorer and choose Unload Project
  2. Once it's finished unloading, right-click on Foo.csproj (Unavailable) in Solution Explorer and choose Edit Foo.csproj
  3. Search for ACL.ascx and compare the XML markup for that file to another "good" file that isn't generating the error, there' likely a subtle difference there which is causing the error
看春风乍起 2024-11-14 15:30:29

我遇到了类似的错误。

我的情况是这样的:

root/page.aspx
root/page.aspx.cs
root/page.aspx.designer.cs
root/X/page.aspx

由于某种原因,有人将 page.aspx 文件复制到 X 文件夹,甚至从我的 Web 应用程序项目中删除该文件,部署项目仍然存在问题。我还注意到,即使使用不同的名称(例如 x 文件夹中的 page.aspx 副本,问题仍然会出现)。

仅当我从 X 文件夹中删除文件 page.aspx (或它的任何名称)时,它才起作用。

I was getting a similar error.

My situation was the following:

root/page.aspx
root/page.aspx.cs
root/page.aspx.designer.cs
root/X/page.aspx

for some reason someone copied the page.aspx file to the X folder, and even removing the file from my web application project, the deployment project was still having problems. I also noticed that even with a different name (e.g. copy of page.aspx in the x folder, the problem would still arise).

It only worked when I deleted the file page.aspx (or whatever name it had) from X folder.

南风起 2024-11-14 15:30:29

就我而言,我通过从 MyFile.aspx 文件中删除 CodeFile="MyFile.aspx.cs" 属性解决了该问题。我认为发生错误的原因是 CodeFile 属性的优先级高于 MyProject.csproj 中的值 ASPXCodeBehind

In my case I have resolved the problem by deleting the CodeFile="MyFile.aspx.cs" attribute from the MyFile.aspx file. I think the error happens because of the CodeFile attribute has greater priority over the value <SubType>ASPXCodeBehind</SubType> in MyProject.csproj.

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