How do I configure a Web Application project for working with html pages without .Net code?
Asked Answered
A

0

5

We have a few html pages in one of our solutions that are meant to be extremely simple, client side only, pure html+javascript pages that access our web api. The api itself is in a web application project in the same solution.

We are now using a web site project to contain those files, but it is getting harder and harder to manage that project, since it's information is placed on the solution, and most of it's aspects cannot be controlled like they can on a msbuild project file.

I'd like to migrate those html files to a web application project, but I'm struggling to make it as basic as possible. For instance, I do not want to generate any dlls on the project. It should be in the solution just to provide access to the files and to enable us to control what goes to the _PublishedWebsites folder on the build by setting the build action on the files. We need this because there are some miscellaneous files in the project that should not be published.

I tried creating an empty web application and removing most things from it, by editing the csproj file. I managed to delete all references and the whole Properties special folder (along with the AssemblyInfo.cs file), but when I run the build command, I still see a dll created along with the obj and bin folders. Then, I tried faking the build target on the csproj file, like this:

<Target Name="Build" />

Now when the project is built, no dll/pdb is created, but the obj and bin folders are still there. Next, I tried setting the outputpath property to the current directory, like this:

<OutputPath>.</OutputPath>

But even then, the obj folder is still created.

EDIT:

I just found another common msbuild property that controls where the files inside the obj folder are placed. After placing this in my csproj file:

<IntermediateOutputPath>.</IntermediateOutputPath>

I now get no folders generated on build, which is nice.

There is a small problem now though (and I'm not sure how and where exactly this process happens) when I open the solution or reload the project in Visual Studio. Even though the project is not being built at this time, some files are still generated:

Autogenerated files on load

I feel the current approach is enough for my requirements, yet I'd really like to know if there is a more elegant way to achieve that. Thus, the question holds: Is there a way to make the web application project work as if there was no code file in it, effectively disabling output generation (bin and obj folders, and the dll/xml/pdb outputs)?

Armalla answered 13/11, 2014 at 18:55 Comment(3)
Why is it a problem that the obj and bin folders are created? Are they deployed when you publish?Ambulatory
Yes. The bin folder is published alongside the files marked with build action Content. Now that I think about it, the obj folder is obviously not published... hmm, this may actually be enough in my case. Still... the question stands ;) And btw, I just found another thing I could use here to prevent generation of the obj folder, will update the question to reflect that.Armalla
I'm sorry, I forgot to reference you in the last comment @JohnSaunders. I think that stubbing the Build target may be enough for my needs, though as I said, I feel the question is still open.Armalla

© 2022 - 2024 — McMap. All rights reserved.