Visual Studio Project: Properties/Settings.settings Missing - visual-studio

I've checked out a solution from source control and opened it in Visual Studio. My assumption is that this solution compiled at one time (two years ago) and was deployed.
There is a project that contains datasets which I will call the "dataset project". The datasets have connection strings defined in the InitConnection() method in Designer.cs files that are looking for a Properties namespace.
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
private void InitConnection() {
this._connection = new global::System.Data.SqlClient.SqlConnection();
this._connection.ConnectionString = global::<some namespace>.Properties.Settings.Default.<some connectionStringName>;
}
In Solution Explorer, I see a Settings.settings file that appears to be "missing." Indeed, the Properties folder is empty when I check it's contents. The missing settings are compile errors in each dataset.
I've attempted to set the connection strings of the datasets to None, but it tries to save the new value to the .settings file, which fails with a "Warning 22 The custom tool 'SettingsSingleFileGenerator' failed while processing the file 'Properties\Settings.settings'.
" message -- ostensibly because the .settings file is missing.
A little more digging reveals a full compliment of connection strings found in another project which references the dataset project. But the dataset project does not (circularly) reference this other project and would have no way to use its connection strings that I'm aware of.
Can the .settings file be regenerated for the dataset project? Any reason why someone would delete .settings in the first place?
Thanks!

Figured it out.
I used Visual Studio to delete the phantom Settings.settings file under the Properties folder (the "phantom" file icon that the project thinks should be there because it's listed in the .csproj file). Then I opened the project Properties and went to the Settings tab. Visual Studio prompted me to create a new settings file. I happily obliged, and VS automagically imported the settings from app.config.
So it seems there is a way to regenerate the Settings.settings.

Related

Can't add .tsx files to Node.js Web Application project

I created a new Blank Node.js Web Application in Visual Studio 2015, and I'm unable to add .tsx files to my project and compile them. When I do so, the created .tsx file is put into a Virtual Project instead, even though it is present in the actual project as well. The project is set to compile JSX expressions as React calls.
It took me some time to track down what's happening behind the scenes, and what happens is that when a .tsx file is created in the project (through Add -> New File), it is created as a Content entry in the project's XML file, instead of a TypeScriptCompile entry. This is clearly an error.
I can fix the issue by manually editing the project's XML file, but no way I'm willing to do that for actual production in 2016, with hundreds of files.
Step-by-step guide to reproduce the error
Create a new Blank Node.js Web Application project
Create a new .ts file in the new project
Create a new .tsx file in the new project
See that the displayed "host project" of the .tsx file (check the top-left corner of the editor window) says "TypeScript/JavaScript Virtual Projects".
How can I make it so that .tsx files are included in the project exactly how .ts files are?
Edit
This is not a problem with a HTML Application with TypeScript project, but that project type contains a lot of unnecessary C# bloat that I don't need.
I can fix the issue by manually editing the project's XML file, but no way I'm willing to do that for actual production in 2016, with hundreds of files.
This has to do something with the project template, and is likely a bug. A possible workaround in the meantime is creating the new file as a .ts file, and then renaming it to .tsx.

change solution file to a different folder

How do I change the folder of my existing solution file (sln)?
It's right now inside one of my project's folder; if I cut the solution file and paste it in the root folder,it doesn't load any of my projects.
Open solution explorer in Visual Studio and select the solution.
Click on File > Save MyProject.sln As ...
and choose the new location.
The solution file is just a text file. You should be able to move it and then edit it to make sure that any relative paths referenced in the file are correct.
I've also been able to right-click on the solution file in the solution explorer and then use save-as to save it in a different location. That doesn't seem to work everytime for me though.
Open a blank solution, save it to a location where you would like to move. Then add "Existing Project" and select the Old.sln file to add all the projects under the old solution file.
I just had to do this with some legacy projects I inherited so thought it might be worth documenting...
After upgrading from VS 2005 solution, I noticed that the solution file was at the same level as the project files. Our standard is to have the solution file one level above.
Opening the solution file in 'Notepad' I see the following:
Add required relative path to each of the project path and save in correct location:
In my case to bring up one level 'BloombergPriceRequestService\'
SO project line(s) will look like this:
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloombergPaydownService", "BloombergPaydownService\BloombergPaydownService.csproj", "{17DDDD3E-CD39-48B4-BE3F-71E550FCBBFC}"
EndProject
Global
Don't forget to delete your old solution file!
if I cut the sln file and paste it in
the root folder,it doesn't load any of
my projects
Do this anyway, and try to open the solution. It will tell you that some projects couldn't be loaded: ignore the warning.
Then, go ahead and delete all the projects from the solution. After this right click the solution and select Add => Existing project and browse to your project file. Repeat for all projects in your solution.
Sometimes, the solution file may contain more than 5 projects attached to it.
In that case, Creating the new solution and adding projects to that is cumbersome and takes more time.
You can just edit the solution file to load the projects correctly.
Steps to do
sdas
1. Open the solution file in notepad or any text editor.
2. update the path which is underlined and made bold.
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloombergPaydownService", "BloombergPaydownService\BloombergPaydownService.csproj", "{17DDDD3E-CD39-48B4-BE3F-71E550FCBBFC}"
Save the file and open in Visual studio.
Editing the solution file is a hazardous way to do things and I found a better way. Just create a new solution and add copies of the folders containing the various projects (in their respective folders) to the project.
You need
to select solution in solution explorer
then to find button File -> SaveAs solution.sln as
Press it
There are two ways you can do it:
Simply delete the entire project and create the entire project again in the other folder ( which is not recommended).
Here are the steps to follow without missing any files.
a. Goto Source control explorer Create a new folder or Just move the solution to which you want to move the folder to.
b. Load the solution in your local and it will prompt a message saying that do you want to reload it from source control click yes.
c. Once we load the solution you will see that the project you have moved won’t be loaded (Since we moved to the other folder)
d. So now, Remove the project which was not loaded and then add it as an existing project
e. I am sure that if you have added nugetPackages they won’t get loaded.
f. Goto file explorer of the particular project open the .csproj file and try to check the packages location, Error condition, Project reference and Import and apart from them if there are any
Which are pointing to a directory.
g. The simplest way is just adding some nuget package and see what is the path generated by visual studio.
h. Once we change the locations they will be loaded in references
i. After adding references try to build the solution and it will throw some build errors because we moved the project from one folder to other.
j. Add the project reference wherever needed after moving the files
k. Now the build will be succeeded.

Change namespace/filesystem folder names in Visual Studio

I'm trying to change a namespace in Visual Studio.
My folder structure looks something like this:
GameAlpha/
GameAlpha.sln
GameAlphaRelease/
GameAlphaTest/
GameAlphaLevelEditor/
These include namespaces like GameAlphaRelease. I want to change all this to GameBetaRelease.
Before this process, it built fine.
First, I changed the solution and project files from Alpha to Beta. Then, I did a "find-replace-all" on the namespace. Finally, I went through the properties of each project and changed the "Assembly Name" and "Default Namespace" to the appropriate Beta title.
However, now the solution does not build. The error is:
GameAlpha.accessor: The reference to 'GameAlpha.exe' was not found in
the list of this projects references.
(Project: GameBetaTest)
What am I doing wrong? If I remove project GameBetaTest, the solution builds just fine.
Also, what is the preferable way to change the names of the folders in the file system?
The following steps normally work for me:
Use the standard project rename (this renames the project, but not the Project Directory). If you want to change the directory as well, close down the solution, rename the directory, open the solution, remove the old project (which is now unavailable) and add the project from the new location.
For each project for which it applies, remove and re-add references to other projects in the solution if there are any inter-project dependencies.
Adjust the project properties for each changed project.
Verify/adjust build scripts.
Verify/adjust the build order.
Clean and rebuild all.
If you do a package/class rename, make sure you do it separately (before, while everything is "still working") so that VS will update the internals as required. YMMV and there are some issues with files "linked" between projects.
Rename the physical project directory
Note: The physical path property is recorded in the .sln file so you cannot just rename the folder in Explorer.
a. Close the solution and the IDE
b. In Explorer: Change the directory name to the new name.
c. In Explorer: Open the .sln file with a text editor.
c. Change the directory name to the new name and save.
d. Restart the IDE and open the solution from the File, Recent Files menu if it doesn't start automatically.
e. Click on the Project folder of the Solution Explorer and check the path property in the properties at the bottom. It will now be referencing to the new project folder.
Here I found it

Visual Studio Copy Project

I would like to make a copy of my project. I would rather not start doing it from scratch by adding files and references, etc. Please note that I don't mean copy for deployment. Just plain copy.
Is there a tool in VS to do this? I am using VS 2008
Just create a template;
From your project choose: Project - Export Template
The wizard will let you define
Template name
Template Description
Icon
Preview image
Then it zips up your project into 'My Exported Templates' directory.
You also have the option to make your template available when you create a new project.
When you use your template to create a new project, the namespace will be correct for 'your_new_project_name' throughout every file, all references correct, everything perfecto :)
You can send the .zip file to anybody, and they must copy (not unzip) the .zip file into Templates\ProjectTemplates directory for them to use too.
I made an ASP.NET MVC template with folders, layout page, viewmodels etc arranged just how I like them.
NOTE:
If you have an empty folder in your project, it WON'T be added to the template, so I just added an empty class appropriate to each folder, and a sample picture for images folder.
If you want a copy, the fastest way of doing this would be to save the project. Then make a copy of the entire thing on the File System. Go back into Visual Studio and open the copy (by right clicking on solution => add existing project => open the copied project). From there, I would most likely recommend re-naming the project/solution (Steps of Safely Renaming Project are in the following link) so that you don't have two of the same name, but that is the fastest way to make a copy.
It is highly NOT ADVISABLE to copy projects at all because the some config files formed internally like .csproj, .vspscc etc. may (and most probably will) point to references which belong to previous solutions' location and other paths/locations in system or TFS. Unless you are an expert at reading these files and fixing references, do not try to copy projects.
You can create a skeletal project of the same type you intend to copy, this creates a proper .csproj, .vspscc files. Now you are free to copy the class files,scripts and other content from the previous project as they will not impact. This will ensure a smooth build and version control (should you choose to be interested in that)
Having said all this, let me give you the method to copy project anyhow in a step-wise manner:
Go to the project you want to copy in solution explorer and right-click.
Now select 'Open Folder in File Explorer' (Assuming you have the solution mapped to a local path on your disk).
Select the Projects you want to replicate as whole folders(along with all dependencies,bin .vspscc file, .csproj file)
Paste them in your desired location (it could be your same solution folder or even another solution folder. If it is within the same solution folder, then you would be required to rename it, also the .csproj and other internal files to the new name).
No go back to Visual Studio, Right-Click on Solution > Add > Existing Project...
Browse and select the Project file (.csproj file) now from the location you placed it in and select 'open'
This file now appears in the solution explorer for you to work.
You may now have to resolve a few build errors probably with duplicated/missing references and stuff but otherwise it's as pristine in logic and structure as you expected it to be.
I guess if this is something you do often, there's a little (non-free) utility that promises to do it for you: I haven't used it, so not sure how good it is:
http://www.kinook.com/CopyWiz/
There is also this project on CodePlex:
http://clone.codeplex.com/
I will probably give the codeplex project a try, and if it doesn't work I'll manually rename everything and edit the sln file.
I follow these steps and I use the development tool called Resharper ,which is awesome by the way:
So,
Copy the existing project folder to the destination you want
Go to source control and with right click just to the root folder you want and pick "Add items to folder...".Then, a wizard will come up to choose the files to copy (there is no need for some files and the wizard guides you for that reason by default).
Change the name of the solution file (*.sln)
Change the names of the sub-projects if exist.
Use Resharper to change the binding namespaces name (I will automatic do the dirty job with safety).The alternative way is to manually change all namespaces with the new name.
The same action with method names.
Check solution's properties if you want to change.
That's it. You are ready!!!
Following Shane's answer above (which works great BTW)…
You might encounter a slew of yellow triangles in the reference list.
Most of these can be eliminated by a Build->Clean Solution and Build->Rebuild Solution.
I did happen to have some Google API references that were a little more stubborn...as well as NewtonSoft JSon.
Trying to reinstall the NuGet package of the same version didn't work.
Visual Studio thinks you already have it installed.
To get around this:
1: Write down the original version.
2: Install the next higher/lower version...then uninstall it.
3: Install the original version from step #1.
The best way is actually to create a new Project from scratch, then go into the folder with the project files you want to copy over (project, form1, everything except folders).
Rename the files (Except for form1 files) for example: I copied Ch4Ex1 files into my Ch4Ex2 project but first renamed the files to Ch4Ex2.
Copy and paste those files into the Solution Explorer for the new project in Visual Studio.
Then just overwrite the files and you should be good to go!
Old thread but I hope it helps anyone looking for this answer!
The easiest way to do this would be to export the project as a template and save it to the default template location. Then, copy the template into the exact same directory on the location you want to move it to. After that, open up visual studio on the new location, create a new project, and you will get a prompt to search for a template. Search for whatever you named the template, select it and you're done!
I have a project where the source files are in in a folder below the project folder. When I copied the project folder without the source folder and opened the copied project, the source files are not missing but found at the old location. I closed the project, copied also the source folder, and re-opened the project. Now, the project magically references the copied source files (both the new path showed up on "save as" and a change in a file has been saved in the copied version).
There is a caveat: If not both old and new project folders are below a used library folder, the above-mentioned magic discards also the absolute reference to the library and expects it under the same relative path.
I tried this with VS Express 2012.
My solution is a little bit different - the computer that the package resided on died and so I was forced to recreate it on another computer.
What I did (in VS 2008) was to open the following files in my directory:
- <package name>.djproj
- <package name>.dtproj.user
- <package name>.dtxs
- <package name>.sln
- Package.dtsx
When I did this a popup window asked me if the sln file was going to be a new solution and when I clicked 'yes' everything worked perfectly.
After trying above solutions & creating copy for MVC projects
For MVC projects please update the port numbers in .csproj file, you can take help of iis applicationhost.config to check the port numbers. Same port numbers will cause assembly loading issue in IIS.
I use Visual Studio 2013 where Project > Export Template is not an option. Here is what I use to clone a project.
From your solution:
File > Export Template > select project to make template from, note save path
Download and install VS 2013 SDK Here
Create new VSIX project under Extensibility
From the VSIXManifest Dialog select the Assets tab
Fill in the Author textbox
Choose "Project Template" for Type and Browse to add the exported template (saved at path you noted in step 1)
Save and build the VSIX project. Go to the VSIX project's .../bin/Debug folder and double click to run the .vsix file
Start new instance of Visual Studio and you should see your template under whatever project type your template is. Create a new project from your template
You will have to re-add any dll references
Trick the Clone from repository tool
Open the project location in file explorer.
Copy the path to any browser (aka open the project location in the browser).
Use the address from the browser as the source repository for cloning.
Relax and enjoy the no error clone.

Visual Studio - Fixing the error "A file of that name is already open"

Occasionally (usually after having updated my .sln file in source control) I get a strange Visual Studio error wherein I'm unable to open some of my files. The files in question show up in the appropriate project, but trying to open them results in an error dialog saying "A file of that name is already open."
This is virtually identical to Why does it say "Project with that name already opened in the solution"?, except for files, not projects. The solution given there was does not fix this.
Visual Studio internally maintains a list of currently opened files, to avoid problems caused by opening files more than once. Any number of things (crashes, reboots, updating files in source control outside of VS) can cause this list to become corrupted.
In any case, the problem can be fixed by deleting the hidden Solution.suo file which is in the same directory as your Solution.sln file. This will cause you to lose your current workspace state (open files, window layout, etc.), but it won't have any other adverse affects on your solution.
This is a hidden file, so to see or delete it you either have to enable viewing hidden files in Explorer or use del /AH Solution.suo on the command-line.
Delete the hidden .suo file and edit the .csproj file to remove the lines below:
<SccProjectName>Svn</SccProjectName>
<SccLocalPath>Svn</SccLocalPath>
<SccAuxPath>Svn</SccAuxPath>
<SccProvider>SubversionScc</SccProvider>
Now, reopen the solution to solve the issue.
Do you have any linked files in the solution?
Visual Studio has an invariant that only a single file of a given path can be open at one time. This invariant is hit most often when you have a linked file in your project / solution and attempt to open both the original and one of it's linked references.
Open csproj file of the project and delete following lines:
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
These lines are most probably created due to project is added to visual svn i.e. when project/solution is added to source control project/solution files are updated to include source control integration info and these lines are added which causes issues.
Delete these lines and just reload your project (or solution), this should fix issue.

Resources