Files target attribute question

Apr 24, 2011 at 6:51 PM
Edited Apr 24, 2011 at 7:05 PM

I have a question about how the target attribute in the "files" section works.

Here's my files section:


    <file src="Content\ajax-loader.gif" target="Content\ajax-loader.gif" />
    <file src="Views\Install\Index.aspx" target="Views\Install" />
    <file src="web.config.transform" target="Content" />


While this works, it places the ajax-loader.gif in the Content folder (where it should be), and also in the root of the web application (where it should NOT be). 

Also, if I change the target from "Content\ajax-loader.gif" to "Content\MvcApp\ajax-loader.gif", it does this:

-- [Root]\Content\ajax-loader.gif

-- [Root]\MvcApp\ajax-loader.gif

What I want in this case, is:

-- [Root]\Content\MvcApp\ajax-loader.gif

Any ideas what I'm doing wrong?


Apr 24, 2011 at 8:10 PM
Edited Apr 24, 2011 at 8:11 PM

What you describe is the correct behavior. Without worrying about how the package was built, what really matters is what's inside the package after it's built. Anything inside of the content folder is copied to the project root. If you wanted a content folder inside of the website you'd need:


For more information, look at the Package Folder Structure section on

Hope this helps.

Apr 26, 2011 at 4:53 PM

@dfowler, yes I read all the documentation, and while it does put the files in the correct places, it also puts files in the wrong places.

I tried this:

<file src="MvcApp\ajax-loader.gif" target="Content\Content\ajax-loader.gif" />

... and it put the file in these locations:

[Root]\Content\ajax-loader.gif     <-- this is correct
[Root]\MvcApp\ajax-loader.gif    <-- this is NOT correct

Maybe it's just that there is a better way of creating the folder structure in the application that will be packaged.  If so, can you give me some guidelines?  I tried creating a "\NuGet" folder in the root of my application that contains all the files that should be copied to the destination application, but that simply created a "\Nuget" folder in the destination application root with all the files that needed to be copied.

This isn't a huge deal since I can easily remove the incorrect files from the zipped package file, but is this a bug or am I still doing something wrong?


Apr 26, 2011 at 4:59 PM

Tell me where each file is in your current package and where you expect it to be (like a unit test :)), and I can help you figure out where it needs to go.