Where do I put .less files in my Visual Studio Web Application? - c#

I want to include a .less file in my Visual Studio Web Forms Application. I am running on the default template for VS 2015. Just wondering which folder to put the .less file in, and where I need to reference it (if at all). Currently all .css files are in the "Content" folder - should I just add it in there?
Please let me know if that's not enough information to go on.
Thanks!

for me and my team projects we use "Content" host sub folder for .less file and compiled CSS. when we compile .less file to CSS using gulp or grunt we output file to "CSS" or "Style" folder. you can create Grunt or gulp task to compiled file to CSS or style folder. this is npm package to compile less to CSS https://www.npmjs.com/package/gulp-less
>Content
---->/LESS
---->/CSS/Style

You will only need .less files when building your CSS. I would suggest a folder you don't plan on deploying to your website. You will only need to include the CSS files that are generated in your Content folder.
I've organized my directories as /Content for CSS and /src for any source files. When I publish to the website I only include the /Content folder. All references should be to the CSS file.
Root
/Content (CSS)
/src (less)

Related

WPF Publish - include folders

I have a WPF project that is now finished, and I want to publish the app into an installer that other people can use.
When I publish the project, the project compiles into setup.exe, but on install the folders that I have do not get included.
I've been reading the guides, and made sure to include the files inside the folders as Content or a Resource. I've also made sure they are always copied. When some of my files are copied, they have a .deploy extension, and I need it to be an .xml in order for some function to read them. Images that I have in the app load fine however.
What do I need to do to have my custom files be EXACTlY as they are, xml as xml, txt as txt and so on. Also I have some empty folders, like this TempCF that I use at some point. Do i need to create it via code?
If you go to Project->Properties->Publish->Install Mode and Settings->Options->Deployment in Visual Studio, there is a "Use ".deploy" file extension" option that you can untick to get rid of the .deploy extension being added to your published files:
Empty project folders are not included in the output. Either put a dummy content file in them or create the folder dynamically as needed during runtime.
# Nikola L.
You could try to use the following methods to add the files in your program to the installation package so that you can have the files you need in your installation path. If I misunderstood your question, please let me know.
The steps are as follows:
1.Right-click on the Setup project and select View -> File System
2.In the File System page, right-click the Application Folder (File System on target Machine) and select Add->Folder(named User's Application Data ) -> Fileā€¦-> find the file under your project and select the file you need.
Such as:
3.Right-click the Setup project.
Install your setup package.
You can find the files you added in your installation path.
The result is like the picture below:

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.

What is wwwroot in asp.net vnext

I create new asp.net mvc project in visual studio 2015.The project has a wwwroot file.What is this?
Quoting the official website:
The wwwroot folder is new in ASP.NET 5.0. All of the static files in
your project go into this folder. These are assets that the app will
serve directly to clients, including HTML files, CSS files, image
files, and JavaScript files. The wwwroot folder is the root of your
web site. That is, http://some.hostname/ points to wwwroot, all URLs for
static content are relative to the wwwroot folder.
Code files should be placed outside of wwwroot. That includes all of your C# files and Razor files. > Having a wwwroot folder keeps a clean separation between code files and static files.
Source
It's worth mentioning that the term wwwroot itself is certainly not new and it's actually a convention used across many platforms (including J2EE applications and IIS itself with its c:\inetpub\wwwroot directory).
Similar conventions in the Unix/Linux world are htdocs, public_html and www.
The wwwroot folder is new in ASP.NET 5 to store all of the static files in your project. Any files including HTML files, CSS files, image files, and JavaScript files which are sent to the user's browser should be stored inside this folder.
Code files should be placed outside of wwwroot, including C# files and Razor views. Having a wwwroot folder keeps a clean separation between code files and static files. It brings clarity to the items that will be sent to the server and the items that should remain on the dev machine. If you look at the screenshot, wwwroot folder has css and lib sub folders. Css folder is a place to keep your custom css files, while lib folder is used by Bower package manager. The lib folder contains the packages downloaded by Bower and can contain css, js and images.
The screenshot shows that lib folder has a bootstrap package folder. If you expand it, you will find css, js, as well all other assets related to the bootstrap package.
In MVC4, we used the content folder to keep style sheets as well as scripts folder for referenced scripts. These folders are gone now, so it's important to understand that there is no single folder for style sheets or scripts. They could be in any of the folders within wwwroot.
It's interesting to note that if you wish to reference the css, js, or img files in your razor views, using the ~ keyword ensures direct path to the wwwroot folder. So suppose you wanted to reference site.css in your view, you can access it using the <link rel="stylesheet" href="~/css/site.css" /> syntax.
You can see that the ~ keyword points to the wwwroot folder.

C# Express - Build class project in subfolder

I have a solution in C# Express 2010 which has multiple class libraries in it. When I build my program, the .exe and all of the .dll files are put in the same folder.
Is there any way for me to specify which subfolders I can place the .dll libraries in?
For example, put the main .exe in the root folder and the .dll files in a subfolder called "lib".
You can change your build output for each project. http://msdn.microsoft.com/en-us/library/ms165410.aspx

Embedding a PDF as a resource in WPF application

I want to embed a PDF file (which is basically have Product details, Release notes) and wants to open that file from menu bar. What would be the best approach. I need to use this file in installer also. So i'm looking for an approach in which file will be moved to BIN on compilation and from there installer can access that file.
IDEAS ...
Add the file to the project the builds the EXE (use Add existing file in visual studio). Then right click on the file in visual studio, go to properties, and verify that the build action is "Content" and the copy to output directory is "Always" or "If newer" (whichever suits you).
Then this file will always be copied to the same directory where the EXE resides and your application will be able to access it because it's always in the application's directory.
If the installer just takes the BIN directory then it will also be able to access it because the file will reside in the BIN directory.
Have fun!
Finally i did it in following way:
a. We've a folder which contains notes.pdf (used by installshield).
b. Created a pre build command to copy the pdf file from installshield folder to output directory.
c. use process.start("notes.pdf"); to open the file. As it would look in bin directory first for pdf file and we've already copied it there.
It worked for both Installer version and running application from code.

Categories