If we look at the settings page of a asp.net website project ( press alt+enter ) . It looks like this:
However, no where in the solution / website folder i can find out where these settings are stored ? there is no csproj file created for "website project" .
The reason I am asking this is because when I add the solution to github , and then clone on another machine, the references are lost and the project will not compile anymore. But if i copy the entire project folder to another computer, it compiles fine.
So for sure, there are some settings file that are not added to git repo.
Does anyone have any idea where these settings are stored ?
I will write down what I found later on for anyone's reference. The Contents in the reference list ( as pasted in the image above ) seem to be read real time from Bin folder of the project . So adding a dll file in Bin folder directly and closing/opening the Property page will show the newly added Bin file as reference.
There is a .sln file for website projects, just not where you might expect it. For Web Site projects, it is created in your default Projects location e.g. C:\Users\username\Documents\Visual Studio 2010\Projects\YourWebSite\YourWebSite.sln (or wherever you have your default Projects location set up in Tools/Options/Projects and Solutions).
Related
I am new in mvc and c# and I can't solve following problem:
I am trying to create a folder named "Items" in solution folder.
I have tryed to use CreateDirectory method:
Directory.CreateDirectory("~/Images");
But it didn't work for me - folder wasn't created ..
Partly working solution was to create a folder by :
Directory.CreateDirectory(Server.MapPath("~/Images"));
"Items" folder was created, but it is not included in the solution:
How to create folder in solution directory so that it is included in project ?
(I needs to by done by code not by hand)
You need to understand what solution and csproj file is used for
In general, they're being designed and used for development with Visual Studio, and once the project is compiled, all these files will be ignored and excluded from the deployment package
Directory.CreateDirectory(Server.MapPath("~/Images"));
The code above simply create the directory if not existed yet in the deployment package at run-time, so you won't see it in your solution unless you run the project locally (either debug/release mode, it does not matter here). However, everything will run normally in hosted environment (ex: IIS).
For your information, here's the brief of what solution and csproj is
solution (.sln) file: contains information to manage one or many individual projects, contains build environments (for each project), start up mode (useful when you want to start multiple projects in one run), project dependencies and so on. Take a note that VS also read from suo file (solution user options) which is used to defined user-custom preferences (you should not include the .suo file in the version control, because it's custom settings)
csproj file: define the structures of project, what the namespace is, what is static folders, embedded resources, references, packages, etc.
Lastly, if you create the folder manually, VS will auto include that folder into deployment package AND csproj, but depends on the file type, you might need to change the Build Action and Copy To Output Directory in file properties.
Hope it helps.
A deployed web application on a web server doesn't have any notion of Visual Studio solution or projects. So the Directory.CreateDirectory(Server.MapPath("~/Images")) is the correct way to create a folder inside your web application at runtime but we cannot be talking about including it into a solution because this hardly makes sense in a pre-compiled web application. If you create the directory on your local development machine, you could always manually include the folder to the corresponding .csproj file, but at runtime this will not make any difference whatsoever.
The reason I wanted to create a folder (if didn't exist) was to make sure it exits before I try to store image in it.
After reading posts here and a few google searches I have concluded that the proper way to handle image upload would be
To create (In my case) folder "Images" by hand to be sure it exists
Then storing uploaded img in existing folder:
string path =Server.MapPath("~/Images/"+ UploadedImageName);
file.SaveAs(path);
I have an MVC Web API application created with VS2015 using the new preview C# 6.
The project by default comes with a Dependencies folder and a wwwroot folder. Both of these reside in the root of my project.
In the wwwroot I have an index.html which is trying to reference angular.js which can be found in the Dependencies/Bower folder (the actual path name is $(project_rootDir)/bower_components/.
So in my index.html I simply do:
<script src="../bower_components/angular/angular.js"></script>
When I start IIS Express and check what file the index.html is trying to load through console then I see it's trying to get it from:
localhost:5000/bower_components/angular/angular.js
But the path should be:
localhost:5000/../bower_components/angular/angular.js
But it seems like it cannot reference JS files from outside of the wwwroot folder. So I'm sort of stuck. What can I do? I want to reference the JS files from the Dependencies folder from the wwwroot folder.
EDIT: This answer relates to the new Asp Net MVC Core 1.0 in Visual Studio 2015.
Just wanted to update this as it's taken me a while to do this and google keeps bringing me back here. Short answer is you don't have to copy anything to anywhere.
#rdans answer is right in saying to look at the link (https://docs.asp.net/en/latest/client-side/bower.html) the most crucial element for this question is that to add a bower configuration file as soon as you create a project.
There is a .bowerrc file that also gets created which is what copies the newly installed bower components to the wwwroot folder (currently set to "directory": "wwwroot/lib").
You then have to follow the instructions to add the following code to the StartUp.cs file.
app.UseStaticFiles();
Then when you want to reference the file ensure you have a ~ at the start of the src url.
Hope this helps someone.
The files need to be copied to the wwwroot folder. I guess this should be happening automatically but I was having problems with this earlier as well. I followed the steps in this article to copy the relevent files.
http://docs.asp.net/en/latest/client-side/bower.html
The steps wernt exactly as described. Here's what I ended up doing:
Right click on gulpfile.js
Click on "Task Runner Explorer"
Double click on "Tasks -> Copy"
You should now see a "lib" folder in wwwroot with the necessary files.
When we publish mvc-3 project to windos azure, Is it copy all files and folder under the project name folder, means likes Scripts, Contents, etc ?. I am asking this because i just publish my mvc-3 application to windowsazure and after that when i run it using staging url then it not shown the images, plugin are stop working and when i inspect under chrome then it shows :
If you notice than there are few Scripts ( like sammy.js ) and stylesheets ( like Site.css ) which are present but maximums are not. Can please anybody explain me how can i fix this?
Ok , i found out the root cause, this is happening because each time when i was downloaded the new plugin
i just copy the .js from its source folder and then paste it into my project's Scripts folder. But only after
putting the file inside the Scripts folder does not includes it in the project. You can`t see that file in the
solution explorer until you explicitly include it in the project.There is a button in the solution explorer on the top
of it for show all file, included the files which are not the part of the project.Then Just right click on the
file which you want to included in the project and select option Include in the project. Then only that
file becomes the part of your project. Now you can publish the project and everything will works fine.
Make sure they are included in the .csproj file
Make sure they are marked as Build Action: Content
I have an annoying error that's been popping up, and I don't know where it is coming from. The error is:
Error 31 Unable to copy file "app.config" to "bin\Debug\Framework.Tests.dll.config". Could not find file 'app.config'. Framework.Tests
The problem is, I don't have a bin\Debug folder anywhere, and it does not say from where it is trying to copy app.config. Double clicking on the error doesn't bring me to any code where it is trying to copy, so that doesn't help me either. So I don't know where I should make the app.config.
How can I find this out?
You have added a reference to a file called app.config or Visual Studio did this for you. The file does not exist on the disk, presumably because after adding the reference you later deleted the file.
Search for the missing file in your Solution Explorer, and either delete the reference or create the file.
It is most likely in the root folder of one of your projects, and should have a yellow triangle warning icon showing that the file is missing.
In an MSTest project the app.config is the one that you would like to provide any calls to the ConfigurationManager class.
It resides in the root of your test project.
The bin\debug folders will be created once the project compiles for the first time. Show all files in the solution explorer should help as they are not (and should not) be included in the project.
HTH
You probably do have a bin\Debug folder beneath your project folder, being the build target folder created by Visual Studio when you build your project for the Debug configuration.
My guess is that something (a test framework perhaps) still has the DLL file loaded, so Visual Studio can't delete and replace the existing Framework.Tests.dll.config file with the contents of your app.config. [Note: the project build action for app.config files is to copy it to the target folder renamed to match the executable with an extension of .config appended.]
I have several ASP.NET web projects and their Output folder are set to "C:\Builds\[ProjectName]bin" (instead of the default "bin\" folder). This makes "F5" Debugging not working because the ASP.NET Development Server expects the "bin" folder under the project folder.
I then changed to use Local IIS Web server (http://localhost/webproject1") and manually updated the vdir physical path to my custom output path. However the VS2010 will not load the csproj because it detects the url is already mapped to a different folder location.
I know I probably shouldn't change the Output folder. But wondering if there is an easy way to workaround this? The goal is to make "F5" debugging work with custom build Output folders.
Update due to Aristos' answer:
Thanks Aristos. Unfortunately that won't solve the problem. All my projects already use the Project Reference, so all the reference dll's are correctly copied to the output folder. The reason why F5 debugging does not work is because the output folder is not the normal "bin" sub folder, but in some other path say C:\BuildsOut\Foo\bin.
It seems that in order to use F5 to debug the web project in VS2010, it has to use the default Output path "bin". If you change that, then F5 will not work and even worse your project may not even load.
Ian,
I have been frustrated by the same problem. I finally gave up and put this dirty little fix in place. I added the following to the "Post-Build" event:
copy "$(TargetDir)MyWeb.dll" "$(ProjectDir)bin"
copy "$(TargetDir)MyWeb.pdb" "$(ProjectDir)bin"
This at least lets me debug the site properly and hit my breakpoints.
You place them all on one single solution, you set as the started project your web project, and then you add on your web project the rest dll as reference (right click on web, select on menou "add reference", and automatically gets the latest version of dlls and place them on bin.
Now when you ress F5 if anyone dll project needed is automatic build it, then run the subproject with the new dll inside.
Delete all items in your bin folder for the solution in question, shut down your system and restart. This fixed it for me at least.