Greg B
Greg B

Reputation: 14898

File not found when building a Web Deployment Project

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.

Upvotes: 9

Views: 5195

Answers (4)

Vitaliy Tokarev
Vitaliy Tokarev

Reputation: 1

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.

Upvotes: 0

jcolebrand
jcolebrand

Reputation: 16035

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

Upvotes: 14

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.

Upvotes: 2

Rob
Rob

Reputation: 45789

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

Upvotes: 2

Related Questions