This seems to be the only thing that works:
- If a .cs file is inside App_Code...
- And does not contain extension methods: set the build action to "Compile"; otherwise no other source code in the project knows of its existence.
- And contains extension methods: set the build action to "None"; otherwise you get an error that the reference to
x.Foo
is ambiguous betweenMyExtensions.Foo
andMyExtensions.Foo
.
- If a .cs file is outside App_Code, inside a folder called Helpers, it must have build action set to "Compile," regardless of whether or not it contains extension methods.
I don't understand this behavior. I wasn't sure that ASP.NET MVC contained any special privileges for App_Code, but it looks like it does... but only in the sense that it auto-compiles extension-method containing .cs files, even when the build action is set to "None"?? Someone please explain.