Why does Visual Studio not know that my source is in TFS? - visual-studio

Every now and then when I add a new project to my solution Visual Studio does not register properly that the project is under source control in TFS.
Intially, all seems well. I check in and the project shows up in TFS. My workspace is a Server Workspace.
Next time when I change a source file in this project and try to save it, Visual Studio does not automatically check it out for me, but in stead warns me that the file is read-only.
When I open the Source Control Explorer, my files are there. When I right-click on the project in Solution Explorer and choose "Add to Source Control" I get the warning that the project already is in Source Control. The solution is on-line , therefore this question is different from Visual Studio isn't tracking changes, or checking out files from source control as I edit them.
This happens in VS2013 and VS2015.
How do I tell VS that the project is in TFS?

The solution is to add a few lines to your csproj-file:
Right-click on your project in the Solution Explorwe and choose "Unload Project"
Right-click on your project and choose "Edit xxxx.csproj"
Add the following lines in the first PropertyGroup. I tend to put then after the FileAlignment tag
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
Save the file
Close the file
Right-click on the project and choose "Reload Project"

Related

Visual Studio, Copy files to project directory problem

I have Visual Studio community 2017. coming from eclipse it was just enough to copy file to project directory and hit refresh then files were appearing in project explorer.
In VS, however when I copy some i.e. *.cpp or *.h in windows explorer to project directory, in VS solution explorer I can not see them. switching to folder view I see but can not include them into project.
via drag&drop to solution explorer (project view) I see them but are not part of project and in folder view and actual directory there is nothing.
what is going on with VS? How can I manually copy paste some files into project while they become part of project?
I will note that there's nothing "going on" with Visual Studio in the sense that something is actually wrong with it, it's just that adding files to your project just requires you to actually add them to your solution. Essentially, it allows you to add miscellaneous files to your folders without automatically including them in your build project (for example, if you're working with some test images/files).
To add files/folders to your project you simply right click on your project in the Solution Explorer and then go to Add > Existing Item.... Then, it's just a matter of selecting one (or Ctrl + A/Shift Clicking to select all/multiple files) and then it will add them to your solution.
In the solution explorer pane, click on the show all files button,
it will reveal all files including your pasted file,
Right click on your file and select "include in project".

"Unused" folder with Visual Studio Express?

Is there a way to have a folder for unused stuff with Visual Studio Express?
This folder will be listed, but ignored by builder and other IDE components.
The IDE ignores any file not part of a project in the solution. You can add the folder under the project if you want. Just make sure anything that is in it, don't select "Include in Project" in the context menu (or select "Exclude from Project" as necessary).
For the IDE to ignore files by default, you will have to copy/paste them into the folder manually. If you use the "Add" context menu, it automatically includes it into the project.
In order to see all files/folders regardless whether they are in the project or not, select "Show All Files" in the Solution Explorer. (In fact, I would suggest this is the default via Tools > Options > Projects and Solutions > VC++ Project Settings > Solution Explorer Mode > Show All Files.)

Visual Studio 2012 Business Intelligence SSIS packages missing

I have Visual Studio 2012 solution with multiple BI projects. One of the SSIS projects do not show all the ssis packages in the Solution Explorer (checked in by another teammember). But the missing files are in the TFS (Source Control Explorer) and are visible in the physical folder.
I tried "Show all files" did not work.
I tried adding the file again but the project does not allow that saying "file with same name exists".
Any idea what is going on here
The authoritative source of what's in a project is going to be the ProjectName.dtproj file.
Inside of that will be entries for the packages that comprise the project. For a non-package deployment model, it's trivial to edit the file by hand and make your stuff show up.
It's way too much effort to do that by hand for a 2012+ project deployment model. Open the Project in Visual Studio (ssdt/bids) and right click on the project. Click Add Existing Item (not add package) and then click the "missing" package. Check your .dtproj file in and all is right with the world.
I had the same issue in 2020, I managed to solve it by building the solution.
On the menu select Build-> Build Solution OR Ctrl+Shift+B

How do I open a project without a .sln file in Visual Studio?

I was writing this program all in Vim and now I'm thinking of moving to Visual Studio, but since I didn't start in Visual Studio in the first place, there is no .sln file to open from. How should I open such a project in Visual Studio?
If you have a web project (without a .sln), you must do:
Menu File → Open → Web Site...
And choose the folder where the project is.
If a *.csproj file exists, you can build a new solution by Visual Studio at first. Next, you can open this *.csproj file in Visual Studio.
An even simpler way in Visual Studio is to follow this:
Menu File → New → Project from existing code
Choose the source file location and a .csproj and .sln file is created.
The simplest way to do this (assuming this is not a web project, as indicated in another answer) would most likely be to:
Create a new project (of the desired type), which should also create the solution for it to live within.
In the solution explorer, right click and select "Add > Existing item..."
Insert all individual files that belong in this new project.
It's probably also worth noting that it's a good idea to double check the project setting, namespaces, etc. before you get too far with building up your project to avoid potential issues later.

How to add an existing folder to a Visual Studio project?

I have a web application project made in Visual Studio 2008.
Well, I added a jquery folder and added it to source control and other such things. I forgot to add it to the visual studio project though. How do I add the existing folder now? I've tried just creating a new folder and naming it jquery but it gave me a cryptic error "the directory is already on the disk ... if you want to see this directory then check the Show All Files option in the project file" Yet I looked and saw no such option.
Is the only way around this to rename jquery to jquery2 and then create a new folder via visual studio named jquery and copy all my files into it?
With your project open in Visual Studio, click on your project. Then go to the "Project" menu and select "Show All Files". You should now see any directories or file that are in the directory of the project but not included in the project.
Then, right-click on the folder you want to add, and select "Include in Project" from the context menu.

Resources