FontAwesome files not published to the web server - c#

I'm using fontawesome in one of my web applications. The problem is that not all of the fontawesome files that is contained withing my Content folder is published to the web server.
Is there any way that I can get these files to be published without having to manually copy them?

Please check the following.
1) check if the font files are in your project in visual studio (i.e. event the files are in the the project folders in Explorer doesn't mean it is in visual studio project, see if you can view it in your solution explorer)
2) if you can see it in your solution explorer, right click on it and see if you see an option called Include In Project. if you see this, click on it and it will include the file into your project. Instead, if you see Exclude from Project then it's in your project.
3) right click on the font file again and see if the Build Action property is set to Content.

This actually had nothing to do with the files not deploying. I'm using bundling and minification and unfortunately it seems that MVC bundles are not smart enough when it comes to virtual directories.
A quick fix was to create a physical directory with the files giving me a 404 error.

Related

ASP.NET: Publishing Website doesn't publish Resources folder

I have a website that I'm developing with ASP.NET. I'm using Visual Studio 2015. When I right-click and hit publish website the site publishes correctly except that my resources folder gets left behind. Heres what the solution explorer looks like in Visual Studio
But after I publish it here are the files that get put on Azure (accessed via FileZilla)
How do I tell Visual Studio to publish the Resources folder with the rest of the website?
Likely Answer
Open the Solution Explorer.
Right click one of the files in the Resources directory.
Choose Properties.
You now need to set two properties.
Build Action Content
Copy to Output Directory Do not copy
Do this to all the files that you would like to publish as content to the web server.
File Properties for Web Server Content
Remarks on File Properties
The Build Action property indicates what Visual Studio does with a file when a build is executed. Build Action can have one of several values:
None. Not what you want. The file is not included in the project output group and is not compiled in the build process. An example is a text file that contains documentation, such as a Readme file, that you do not want to publish to the web server.
Compile. Not what you want. The file is compiled into the build output. This setting is used for code files. In other words, we compile the file and the stick it into the bin directory.
Content. This is what you want. 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. The "Content output group" is a list of files that Visual Studio will publish while also maintaining the same directory structure.
Embedded Resource. Not what you want. This file is embedded in the main project build output as a DLL or executable. It is typically used for resource files. In other words, it not only goes into the bin directory but is also embedded within a .dll or .exe file.
Copy to Output Directory. This property specifies the conditions under which the selected source file will be copied to the output directory. The output directory is normally the bin.
See Also
What are the various "Build action" settings in Visual Studio project properties and what do they do?
File Properties on MSDN
If like me you are using Visual studio 2019, just right-click on the folder and select publish "name of the folder"
Steps to add resources to be published (Visual Studio 2017):
1) Right click the resources folder and select "Include In Project"
2) Now you should see Build Action: Content on the properties for the images.
Make sure the contents of your Resources folder have the proper "Copy to Output Directory" property. Right click the files you want to copy over, select Properties, then in the Advanced section look at the value under Copy to Output Directory. Generally this is set to "Do not copy" by default since most things get packaged up in the .dll. Change it to "Copy if newer" to get it to bring over the file. It'll bring over the folder structure as well.

How to include other files to the output directory in C# upon build?

I have some library files needed for my application to work.
My application has a setup and deployment included.
I already know that in order for a library file to be added to the output directory of the application when installing, I just have to reference those libraries inside the .NET IDE before building... the only problem is that these libraries can't be referenced... So I need to be able to copy these libraries to the installation directory of my application... At the moment, I am copying these libraries manually...
Addendum
I also did try to add these library files as an Existing Item to my project and marked each library files' Copy to Output Directory to Copy if newer on their properties but still not getting the solution I want.
Update 1
Thanks for you help guys it helped me solve my problem, I managed to make the solutions you posted work except for one... #Matthew Watson's post.. I even managed to find a solution too so I wanted to share it with you also.
Heres what I did:
I opened the setup and deployment project in my application.
Under the Application Folder Tree, on it's right side, I right clicked..
then clicked Add..
then clicked File
and then browsed for the files I wanted to add to the installation directory
and click open.
But out of curiosity...I am still trying to make what #Matthew Watson posted work...
Update 2
I forgot to update this post yesterday, I already manage to make Matthew Watson's solution worked yesterday. Thank you again for all your help guys.
You can add files to your project and select their properties: "Build Action" as "Content" and "Copy to output directory" as "Copy Always" or Copy if Newer (the latter is preferable because otherwise the project rebuilds fully every time you build it).
Then those files will be copied to your output folder.
This is better than using a post build step because Visual Studio will know that the files are part of the project. (That affects things like ClickOnce applications which need to know what files to add to the clickonce data.)
You will also be more easily able to see which files are in the project because they will be listed with the source code files rather than hidden in a post-build step. And also Source Control can be used with them more easily.
Once you have added "Content" files to your project, you will be able to add them to a Visual Studio 2010 Setup and Deployment project as follows:
Go into your Setup project and add to your "Application Folder" output the Project Output called "Content Files". If you right-click the Content Files after adding them you can select "outputs" and see what it's going to copy.
Note that Setup and Deployment projects are NOT supported in Visual Studio 2012.
You can use Visual Studio Post Build Event - Copy to Relative Directory Location. Which are basically scripts that are executed on build of specified project.
So you can use it to copy binaries you need, before actually running your application.

Images don't show up after VS 2012 Publish

I have created asp.net web project. I have included some files in this project. Following all CSS standards required.
background-image: url('~/Images/sideheader.png')
I can see all pictures when I debug my site. But when I publish my site, I don't see any picture in my site.
Please help me resolve this problem.
When you manually add files (i.e. images/js/css) to a directory and use them directly in your html/css (as per your question) Visual Studio does not know they exist. You need to 'show all files' and then 'include in project' the images/files you want to publish.
Only the files which are visible (=included) in the Solution Explorer in Visual Studio will be published to your server.
You should use it like this :
background-image: url('/Images/sideheader.png')
in this way the relative paths resolves to the correct place .
Your URL isn't pointing to the file. It works fine on the debug server, because when you run it in debug, it starts up a testing server for your project that has a different configuration than the server you published to. Because you have it in a different directory, or have a different home directory configured, it can't find the image.
For anyone coming to this question, this was determined from testing if replacing the relative URL with an absolute one would solve the problem, which took place in the comment section of the OP.
You just need to add your folder images to your project and republish your project. To add the folder, go to solution explorer, click on show all files, right click on your images folder and select include in project. You don't need to change any urls of the images you have used in your css or any where else.
I ran into the same issue, in my case since the Images folder is not recognized by Visual Studio, I had to set read permissions to everyone. Once I set the Image folder permissions, my images showed up just fine.

Build (and Debug) ASP.NET Web Application in a non-default folder location

I have a Visual Studio 2008 solution with an ASP.NET Web Application project. I want to change the default output folder, of said project, to $(SolutionDir)\WebApps\$(ProjectName)\bin. This I can do and when I build I get the expected assembly files in this folder. It doesn't copy the content files (aspx, etc.) to the parent folder but I have managed to fix this by hacking the project.csproj file with a custom build target.
The problem is I want to be able to debug this application using the ASP.NET Development Server, by pressing F5 in VS2008. Unfortunately the ASP.NET Dev server starts, has a "Physical Path", in the project directory rather than the parent of the output directory.
Is there any way to build my web application to a different output folder but still run the asp.net dev server to debug my site?
Thanks.
Short answer is yes, but it isn't pretty. The process I used is given below.
Unloaded the project in VS.
Manually edited the .csproj file to include a post build action that basically copies the content files (aspx, etc.) to the parent of the output folder.
For the debug options I set the project to launch an external executable. The Asp.Net Development server. Also manually set the url to launch.
What I learnt? I wouldn't do this, I'd just stick with the default and create an install/web deployment project instead.

For a Silverlight 4 Visual Studio solution, what needs to be in version control?

I have a Silverlight 4 app that I'm building with Visual Studio 2010. I'm using Mercurial/TortoiseHG to do version control. Which files do I need to check in? By default, it checks in all sorts of .dlls in /bin/debug and stuff. Do I really need those? Or can I just grab code and content files? Do I need to version something to keep track of project properties and references, or is that contained within the .csproj file itself?
You don't need to include stuff in /bin or /obj. This is true of all VS solutions in source control. These are recreated upon every rebuild. Also, for Silverlight specifically, you don't need to check in the XAP file that is generated in the ClientBin of your web app.
From MSDN (via this social.msdn thread):
You can add the following files to Visual Studio source control:
Solution files (*.sln).
Project files, for example, *.csproj, *.vbproj files.
Application configuration files, based on XML, used to control run-time behavior of a Visual Studio project.
Files that you cannot add to source control include the following:
Solution user option files (*.suo).
Project user option files, for example, *.csproj.user, *.vbproj.user files.
Web information files, for example, *.csproj.webinfo, *.vbproj.webinfo, that control the virtual root location of a Web project.
Build output files, for example, *.dll and *.exe files.
It doesn't say anything specific about Silverlight projects though.
Is Mercurial/TortoiseHG integrated into Visual Studio? i.e. can you check out/submit from within VS?
If so, if you right click on the project name and select "Add Solution to Source Control" it should add those parts of the project that it needs ignoring everything else.

Categories