Adding a Class File as Content?

Feb 17, 2011 at 7:04 PM

I have a package that delivers a single class file (Massive.cs), and when it does, it's marked as "Content" so it doesn't compile, and therefore doesn't work. Is there a way around this?

Feb 17, 2011 at 7:06 PM

You're putting it in App_Code. Try Models?

Feb 17, 2011 at 7:06 PM

In theory, it should do whatever VS does by default. i.e. if you drag and drop (or add existing) that same file from the shell into the project, does it end up as Compile or Content?

Feb 17, 2011 at 7:08 PM

Indeed, if it's in App_Code, then Content is the correct behavior, since those are compiled at runtime. VS has a different default Build Action for that folder.

Feb 17, 2011 at 7:17 PM

Makes sense... sort of not really. Bottom line appears to be that if you want to use this thing in a WebApp you have to mark it to compile, even if you pop it into App_Code. App_Code won't work for this - even if you want to put it on a scripted page.

This is only for WebForms apps - Web Sites (like WebMatrix stuff) and MVC should work just fine - but you'll have to move it out of App_Code (where it goes by default) and set it to compile.

Feb 17, 2011 at 7:50 PM

I think you bring up a good issue: there is no easy way to create a package today that brings in code and works equally well for Web Apps and Web Sites. Maybe we need to add special handling that automatically puts code in App_Code if using a web site. So the idea is that you'd put foo.cs directly under Content. In Web Apps it would end up at the root, while in Web Sites in would end up in App_Code.

Right now we have packages like OData.Helper which were written for Web Sites, and are effectively unusable in Web Apps because the code ends up in App_Code.

Feb 17, 2011 at 7:52 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 17, 2011 at 8:06 PM

There's way bigger issues than just app code... but we can fix the app code scenario by detecting certain file extensions