I have website project with a publish profile set up to publish to ~\www\Website (the project source folder is ~\Website)
There is an .xml file in ~\Website\bin that is included in the project (it's the only file from the \bin folder that is) which is required for the CMS (Sitecore).
Looking at the included file's properties menu, Build Action is set as Content and Copy To Output directory is set as Copy Always.
When I run the publish, the file is not copied to ~\www\Website\bin but instead is placed in ~\www\Website\bin\bin.
I've tried changing the "Items to deploy" in the projects Package/Publish properties to "All files in this project" as describe here but the result does not change.
This is quite vexing and I've not been able understand why it occurs. Does anyone have any insight? Thanks.
The basic logic behind "Copy always/if newer" is that the subdirectory structure is preserved when the files are copied to the output directory. Files that are located in subdirectories of your project are copied into the output directory in the same subdirectory structure.
ProjectDir\a.txt -> OutputDir\a.txt
ProjectDir\Subdir\b.txt -> OutputDir\Subdir\b.txt
By default, the bin-directory is the output directory of a web application. So if you put the file into the bin-subdir then it will be copied into bin\bin as you describe.
In order to solve this, move the file to the project directory. It will be copied to the output directory (bin) without a subdirectory.
Related
Wanted to include a folder and static files under it in a c# project to build output. The purpose is to use those static files in program by combining root location of assembly and the folder.
Folder property/properties to set in VS solution to include it and
files under it in build output
It is quite easy and you can directly drag the file or the entire folder to the project on the solution explorer.
And then change every file's property Copy to Output Directory to Copy if Newer.
After that, these static files will be under the build output folder.
This is a gif about the steps of the solution.
I have a project that has a directory called "Data" containing various data files, like XML and XSD files. I have these files specified as "Content" and "Copy Always" and they copy just fine to /bin/ on build with the directory structure intact (ie., /bin/Data/).
I've also added these directories to the .testsettings Deployment list. I've tried to do this both by setting the individual files to deploy, and as setting the directory. In both cases, it just copies the files themselves into the output directory, but does not preserve the directory structure.
How do I tell Visual Studio to preserve the directory structure when copying files to the test output directory? I would prefer not to have to use post-build events. It just seems crazy to me that the test setup is different than the build setup.
Thanks.
Luke
I added 3 html files to my project and the change is reflected in my csproj file.
But to deploy this on to a web server, is it enough if I drop these 3 files in the appropriate directory? Or is there any build/assembly deploy needed because of csproj change?
Html files do not require build, just copy the files
IF you have code behind for aspx files then you need to deploy the dll.
Add the file to your project.
Set the build action to "content".
Set "copy to output directory" to "copy always".
The file should be included in the same folder as the rest of your deployment. You should be able to see it by building it and looking in the \bin\release or the \bin\debug folder. If it's not there, click on the Application Files button and see if it shows up there.
Deploying the HTML files to your web server simply requires you copy the HTML files to the appropriate directory.
The resulting change in your .csproj was really only made to keep track of the files within your IDE but no, you wouldn't need to rebuild/redeploy the resulting DLL just for static files.
I have various files in my Visual Studio Solutions that have to be copied to the bin/Debug folder if I change it.
I tried to set Copy to Output Directory - Copy always but it doesnt work. So how can i make sure that when building these files are copied to bin/debug?
Here a screenshot from one example:
Make sure the build action for the files are marked as content, otherwise they will not be copied while building.
Content - The file is not compiled, but is included in the
Content output group. For example,
this setting is the default value for
an .htm or other kind of Web file.
Are you using the Debug profile? The build section of your properties has an output path which is set to bin/debug if you are using this profile.
I kept getting errors in my log file that messageconfig file not found. It turned out that my application was expecting it in the bin\debug folder. What causes the application to expect so? It seems that when project is built it should copy the config file in bin\debug folder. Am i missing a certain project setting?
App/web.Config files are expected to be in the same directory as the application/web root.
Other, referenced config files may be in other directories, as specified in the main configuration file.
If you right click on the .config file, then on properties there is a Copy to Ouput Directory entry.
This should be set to either Copy if Newer or Copy always, if this is set to Do not copy, the .config will not by copied to the debug/release folder where it is expected.
Config files are expected to be in the same location as the executing assembly.
Check out this SO question:
.NET 2.0 Application Settings (user.config) file location
You could set the files build action to "Copy always"..
usually you only need the .exe. Try to clean and rebuild your project..
Hope it helps