Can't Change Project to x86 in Configuration Manager - visual-studio

I have a solution with over 170 projects in it. I recently needed to add two more projects to this solution. For reasons that are not relevant to this question, the solution is built as at x86.
When I open Configuration Manager, and scroll to my new projects, they say "Any CPU". To change that I select <New...>:
It brings up a dialog to make the new entry. I fill it out like this:
When I select OK, it flashes for a second, then goes back to "Any CPU":
I also tried selecting <Edit...> and I get this:
The Remove button is locked out and I don't have any other options.
How can I get an x86 option setup for my new projects?

I faced a similar problem when I converted C# projects into C# SDK style projects.
I found that after conversion, the project type GUID in the solution file did not change from Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = ... to Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = ....
Solution of this problem in my case was to delete this project from VS solution and add it again. You can also manually edit solution file (.sln) and change wrong project-type-GUID.
In your case, try to check the project type GUID in the solution file and change GUID manually. The list of project type GUIDs can be viewed here.

Related

If i want to make a copy of my c# project in the same workspace how can i do it?

In other words lets say i have already completed a project using visual studio. Now i want to make a separate project that is identical to the already completed project(except for some future changes).
How can i do this while keeping the new project in the same workspace as the original without:
creating a new project and copy pasting code over
copy-pasting the folder that holds the project and changing the name of the folder
I'm asking because there must be a better way to do this than the two options above.
Right click on the solution and "Open Folder in File Explorer"
Copy the project folder
Rename the new Project folder
Open the new project folder and rename the .csproj file
Right click on the solution and "Add" "Existing Project" to the solution
Open the "Properties" for the new project
Under "Application", change the assembly name and default namespace
Select "Tools", "Create GUID", Option 6, "Copy"
Under Assembly information, change the name and product
Paste in the GUID and clear the "" suffix
Rename the namespace in the source files to reflect the new
namespace from above.
Depending on your needs, you could get by with a subset of these steps (e.g. steps 1 and 2), however, I think a complete copy requires all of the steps mentioned.
The second option is exactly what you should do: duplicate the folder containing your project and then rename it.
To make this work, you might also have to change the GUID used by the project to avoid clashes. Visual Studio is supposed to do this automatically if another project with the same GUID already exists in the solution. If something goes wrong, you can do it manually by editing the project file (it's the field called ProjectGUID). It's just a standard GUID value, so use any freely-available GUID generator like the one bundled with Visual Studio or one you find online.
Why should there be a better option than this? What would that "better" option look like? It's not like there's going to be a menu command for it, this isn't a very commonly used feature. Most programmers use a source control system that handles branching/duplicating for them automatically and [mostly] without pain.

Add a folder structure to a Visual Studio Solution

Is it possible to add a folder structure to Solution Items without manually adding each level of the tree?
We have a multi project solution which requires several third-party libraries, at least one of which has a multi-layer tree.
We have a libs folder at the solution root level, alongside all the other projects.
The answers regarding Show Hidden Files, etc. don't work for solution items, only within a project.
Is there any way to get around this?
Do we have to add them folder by folder if we want them at the solution level?
(A similar question has been answered many times regarding Visual Studio projects. However my question is about Visual Studio solutions.)
Solution folders are just logical groupings of items. I don't think they relate to the file structure on your system. That is why you don't see them with a "Show hidden files" sort of functionality. You must right-click the solution, add a new folder, and then right click on the folder to add existing items or nested folders.
Not quite an answer to the question, but to view folders on the file system within Visual Studio Solution Explorer there is now a way of switching views between the solution and the folders. Here is the button to switch:
Clicking/tapping on this brings up "Solution Explorer - Views" content showing all available solution files and option for "Folder View":
Double clicking the "Folder View" shows the folders in the underlying file system:
Screen shots taken with Visual Studio 2019 16.10 preview 4, but this has been there for a while now.
I was looking for something similar and came across this thread. I had several data files that I wanted included with my solution but weren't specific to any one project in that solution.
I'm using VS 2019 and discovered they now have "Shared Projects" in C#, VB and C++ flavors. These projects don't build anything, but it's a convenient way to include some related directories/files.
Add a new Shared Project to your solution with the desired directory name.
Copy all your secondary files to the new directory.
Select "Show All Files" in the Solution Explorer.
Select the files, then right-click and select "Include in Project".
You can now view the file structure and open the files as part of your VS solution but VS will not try to build anything for that Shared Project.
If you have Source Control enabled, VS will also check-in those files (unless you mark them as excluded).
One option is to add an extension: "Add Folder as Solution Folder"
With this extension you can do this:
right click the solution > Add > Add Folder as Solution Folder
If I get you right, you'd like to have the projects organized in your solution.
Not sure if this fit your scenario, but if you choose a ".sln" (switch file-extension in the filebrowser-Dialog) when adding existing projects to your actual solution it will add all the project organized as they are saved in the sln to add.
(VS2017)
PS: Yes, I see this is a 7 Years old post :)
One Option would be to write a little exe and add this as external Tool to VS. Basically you would need to edit the sln file (plain text) by adding the folders as "Projects"
...
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mycsproj", "
[somerelativepath]\mycsproj.csproj", "{projGUID}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FolderName",
"FolderName", "{FolderGUID}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SubFolderName",
"SubFolderName", "{SubFolderGUID}"
EndProject
...
{FAE04..} shall be the Project Type GUID for CSproject
{2150...} would be the Project Type GUID for Project Folder
And define the hierarchy in the section
...
GlobalSection(NestedProjects) = preSolution
{projGUID} = {SubFolderGUID}
{SubFolderGUID} = {FolderGUID}
EndGlobalSection
...
Now it's up to you to write some exe, reading the folder info of the libs from the disk and write according Project-Folder Infos in the sln. This should not be a huge effort :)
So whenever you collect multiple projects to your solution, you hit your ext tool and have the connected projects structured fine.
And still I might be on a false track understanding your issue:)

How do you remove the bindings from a VS Team project?

How do you remove the bindings from a VS Team project, is it just a matter of deleting ".vspscc" files?
What is the best way to do this, say I have a project on CodePlex and it is time to package it up for release, but by default the bindings come with the source so when others open the solution it interferes with it.
The simple way to unbind from source control:
Open your project
File -> Source Control -> Change Source Control
Select your project(s)
Click "Unbind"
What worked for me (under TFS, not codeplex)
Copy or move the project folder out of your workspace (I put it in c:\temp), and then open it in VS2008.
Visual studio then shows the following prompt:
The solution appears to be under source control, but its binding information cannot be found. Because it is not possible to recover this missing information automatically, the projects whose bindings are missing will be treated as not under source control.
After this, another dialog appears, as follows:
The solution appears to be under source control, but its binding information cannot be found. Because it is not possible to recover this missing information automatically, the projects whose bindings are missing will be treated as not under source control.
And you can chose Temporarily work uncontrolled, or Permanently remove source control association bindings.
Select the latter, do a Save All, and reload the solution. Profit!

Adding a new project to an existing solution in TFS

I added a project to an existing solution that is currently under source control using TFS, but for some reason I cannot check in the new project. When I view my pending changes, none of the files in the new project show up. None of the files have a plus (for a new file) next to them. What did I do wrong? How do I fix it? It's time to check in.
The problem is the solution has lost its binding. That's why it's not checking out automatically when you add the new project.
In order to restore the binding in VS 2010, go to File->Source Control->Change Source Control. Look for the "Solution: your solution name" and if it's not bound it will say "no server". Click on it and then click "Bind" from the toolbar.
in Visual Studio 2012/2013 it's File->Source Control->Advanced->Change Source Control (Thanks to danglund).
This should create a new vssscc file that is correctly bound. Now add the new project and everything should work correctly.
I was also having the same problem, this is how I fixed it:
Go to Visual Studion: File->Source Control->Change Source Control
Find your project there, its status would be "Invalid", Click on it and press "Unbind". Now go back to Solution Explorer and Remove your project. Add this project again into the solution explorer solve the problem.
Good Luck!
Click on the Team Project name in Source Control Explorer
File -> Source Control -> Add Items to Folder...
Follow the wizard.
Head over to Source Control Explorer and browse to the place in the tree which matches where the new project is at for your solution. Add the files there.
However, I'd be concerned that you modified the solution file and it didn't ask you to check that out. What you may want to try doing is manually checking out the solution file, then readding the project to the solution and seeing if it takes then.
You shouldn't need to drop to the command line - this is a pretty straightforward operation.
Open the solution. Select the project (make sure it is in the solution).
File -> Source Control -> Properties will bring up the binding dialog.
Bind the project to source control.
You should now see + signs next to all your files. The key is that that a .vssscc is added for your project to version control.
If that fails, open your csproj in notepad (after making a backup), and ensure any version control bindings are removed, then try again.
Unfortunately, I'd wager that your best bet is to manually do the check-ins through the command line. I've ran into situations where the Team Explorer UI grows out of sync with what's actually happening in source control, and manually fixing things through tf.exe was the only way to resolve it.
That said, normally, adding a new project to a solution isn't a hassle.
TFS can simply do not know about your project existed. Just add your project files through Source Control Explorer and re-load the solution.
While loading of a solution it can ask you to bind your project to source control. Let it do so by clicking Bind button - it should do all the magic for you.
Make sure you get the latest version of the solution
Check out the solution file
Add the new project
If the newly added project was previously under (another) source control, that might mess things up, make sure to "unbind" it before adding it. (See source control bindings somewhere under the "file" menu in Visual Studio)
You shouldn't need the command line.
I had this same problem in VS 2019, where I had added a new project to an existing solution, and the project wasn't showing up in pending changes. Right-clicking on the project and going to Source Control only had an option to "Add Solution to Source Control".
Using the above answers, I started down the File --> Source Control path, which then yielded an option to directly "Add selected projects to source control". Taking that option solved the problem, so that now the new project shows up in pending changes. NOTE: I'm adding this answer since it's still an issue in VS 2019, but has an easier solution now than in the past.

Solution with 2 projects - sharing Properties.Resources

In Visual C# 2008, I have a solution with two projects.
First project contains Form1 that displays one Label with Text set to a string from Properties.Resources, like this:
label1.Text = Properties.Resources.MY_TEXT;
In the second project, I "Add as link" this Form1 from the first project. I want to show this form, so it displays the same as when called from the first project. It should show a label with text Properties.Resources.MY_TEXT defined in the first project.
Unfornately, the second project doesn't build with the following error message: "The name 'Properties' does not exist in the current context".
Is there any way how to resolve this? I have tried to "Add as link" the "Resources.resx" file from the first project, but it doesn't help.
EDIT: I found that if I add Project1 as a Reference in Project2, everything works. I also had to change Access Modifier in the Project1 resources from Internal to Public. Is this the right approach?
Thank you,
Petr
Yes that is the right approach (referencing one project from another). A pattern you may like to apply is to have one project that has all your reference/lookup/settings in it. Then you don't need to work out dependencies between your UI projects.
Your approach of making the resources public is the correct.
You also asked about combining assemblies. Have a look at the ILMerge tool.
You should add "using MyOtherProjectNamespace" so that you can access its properties

Resources