I have 2 projects on tfs. One tfs project with the main sln and the other tfs project contains a bunch of sub csproj. I called the one sub csproj into the main project then checked in. After a couple minutes I get a build error on tfs saying that the sub project is missing. I look closely at the path its going to in the log error on tfs and it is clearly not where the project is stored(it is checking within the current tfs project for the file).
Is there a way to config tfs to know where to look for the files or do I have to move the the project to the same tfs project or get the dll and put it into the sln?
i.e.
TFS project A -> Solution1 -> Added Project 1
TFS project B -> Project 1
Project1 in TFS A is on TFS under TFS B
Assuming you are using classic TFS version control (TFVC), the answer is yes. You simply need to setup a proper mapping in your build definition. From Visual Studio, Edit your Build Definition, select the Source Settings tab: there you can add as many mapping you want and the layout for build can be different from the layout in Version Control. This documentation page has all details and option, not that it may use the old term Workspaces instead of Source Settings.
Related
We have a C# solution with multiple projects. We are managing version control for the solution using Github desktop, i.e., outside Visual Studio. After pushing new code to GitHub on a new machine with a fresh install of Visual Studio 2019 community edition, when I add a new file to the API project in the solution, I find that the file gets added to the .csproj file as follows, and the IDE never includes the file in the build, debugging, code completion etc.
<ItemGroup>
<Compile Remove="Controllers\TestController.cs" />
</ItemGroup>
I also see a + sign next to the TestController file in Solution Explorer. Hovering over the + sign brings up the message "pending add."
Why is this happening? And is it safe to just remove this itemgroup block in the .csproj file? Is there a way to prevent this behavior for new files added to the project?
Details
Context:
C# solution with 5 projects - (1) WebAPI, (2) Identity, (3) DataAccess, (4) Services, (5) Shared libraries. Editing using Visual Studio 2019 Community Edition.
Full timeline:
Solution pulled from GitHub.com using GitHub desktop
Files added to DataAccess and Services project using Visual Studio. Everything was fine
New branch created in GitHub desktop. New files added to the branch using GitHub desktop and pushed to GitHub.com using GitHub desktop
Code merged with parent branch by project administrator
Local solution synced to remote repository using GitHub desktop
--- alert: problem seen now ---
New file (TestController) added to the API project using Visual Studio. This file does not become part of the build. IDE does not highlight ApiControllers, ControllerBase etc, does not indicate errors for mis-spelt services, pressing F11 on ApiControllers gives error message "cannot navigate to the symbol under the caret."
Google search suggests checking on .csproj file. Here I find that the new file is within the 'compile remove' block.
Is it safe to edit .csproj file in Visual Studio 2019?
If you know what you're doing and you do it correctly, sure. Otherwise, not so much.
Why is this happening? And is it safe to just remove this itemgroup block in the .csproj file? Is there a way to prevent this behavior for new files added to the project?
It's happening because a file showed up in the project subdirectory that Visual Studio doesn't have as part of that project. So it adds the <Compile Remove... /> element to exclude it from being compiled as part of the project. It is safe to remove the element, but in my experience it just shows up again.
As a general rule, you should not be adding files to project directories managed by Visual Studio, except by using the Visual Studio UI itself. It's not clear from your post why you are doing this. The directory you apparently are adding files to is your project directory. It should only have files that do in fact belong to the project.
The best fix is to not try to add files to a project directory when they shouldn't be part of that project.
You may have an XY Problem. If you can post a new question in which you explain the scenario in which you've added the files that don't belong, and ask for guidance to accomplish whatever broader goal it is you have, but without running afoul of Visual Studio's rules, you may get a better answer than "don't do that".
I think I have identified the problem. I believe what happened is that once the local branch was pushed to remote, further changes to the project made using Visual Studio were not being integrated into the project, even though I was not formally tracking the project in Visual Studio.
git status showed that I was still on my initial local branch. I did the following to sync with the remote parent branch and then start a new local branch:
git stash
git checkout <parent_branch>
git pull
git checkout -b <new_branch>
This switched me to a new branch, and now I am able to edit the file as usual.
I am new to TFS. I have a project of C# win forms. We are maintaining the projects with versions like v2018,v2019...
I have added v2018 project in TFS. It is working fine.
Now I took the v2018 project from TFS and took it out and removed all '*.*scc' extension files and made some changes inside the project and made that project version as v2019. The project is working fine outside.
Now I want to add this v2019 project to TFS as v2019.
But I am unable to add the project to TFS. While I am clicking over the solution and add this to Source control but it is adding only solution file to the TFS.
Why i am unable to add the whole project to the TFS.
Don't know what is the reason.
Under Team Explorer -> Pending Changes -> Excluded Changes you should see something like this:
If you click on that Detected X add(s) you should see a list of all the files that have not been added to source control. Just tick them and then click "Promote"
I noticed that VSTS has an "Add a .gitignore" dropdown with many different platforms/languages options for selection. For example, I could select the option of "Ruby" which I'm assuming would provide a default filter for all file types in a compiled Ruby project which should generally not be checked in to a git repo. However, no option exists in the dropdown for .NET/C#. Does VSTS include some type of equivalent gitignore file within C#/.NET files by default? Or is there some type of default global filter build into VSTS which enforces this?
The .gitignore template for C# is called "Visual Studio".
For the record, the .gitignore we got from VSTS starts with the following preamble which contains a handy link to the .gitignore tailored for Visual Studio projects.
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
If you create a new repository through Visual Studio, then the .gitignore file will be created in that repository.
For local repository:
Open Team explorer
Click manage connections
Click New link in Local Git Repositories
Specify the path and click create
For an empty git repository in VSTS:
Open Team explorer
Click Manage connections> Connect to team project
Choose that repository > Clone
Connect to that repository
Click New… link in Solutions section of Team explorer
Choose a template
Make sure check Create new Git repository
Click OK
Both of these ways can create .gitignore files with necessary content automatically.
You also can create .gitignore file when creating repository or add a .gitignore file to an empty repository by accessing that repository in web browser and click Initialize button (choose a Visual Studio first)
I began working on an .Net Core solution in VS 2015, which contains an ASP.Net Core project and a couple of .Net Core class libraries. The solution was under TFS source control.
I wanted to include some unit tests. Since .Net Core unit test project templates are not included with VS 2015, I decided to install VS 2017 and upgrade the solution. After upgrading, I was able to add a unit test project and everything compiles and runs normally.
When I first opened the solution after upgrading, though, I initially got an error about the solution being treated as though it was not under source control. Based on Google searches, I went into File -> Source Control -> Advanced -> Change Source Control and clicked "Bind" on each project. The three old projects link right up and show up as "Valid", while the solution file and the new unit test project show up as "Invalid". Unbinding, unloading, reloading, and rebinding the invalid project did not help. I can force the project to bind even though it is invalid (against Visual Studio's warnings), and after some tinkering, I can get the solution to check in, but when I get latest on another machine, the three original projects say "Not Available" and the unit test project is not visible.
Other symptoms: project.json is not found when I try to check in (I have to "undo" or "exclude" to check the solution in) and regardless of what I try, the invalid unit test project's folder shows up in the root folder of the directory tree (at the same level as "src" and "Backup") while the valid projects are in the "src" directory. I am inferring this is because the new solution types allow an .xproj file, while the old solutions required project.json, but I don't know what to do about it...
Any ideas on how to relink this to source control would be appreciated! I did not upgrade TFS server when I upgraded VS, but I don't directly have access to it, so hopefully this is not a requirement...
To fix the invalid binding in VS, you could try to follow below steps:
Click the “invalid” project in Solution Explorer.
Open “File | Source Control | Change Source Control”
Unbind the invalid project.
In Solution Explorer, Unload the project.
In Solution Explorer, Reload the project.
Also clear TFS and VS cache, delete the old workspace, create a new one, get all projects you need from TFS source control. Everything should be back on track.
Sledgehammer approach not normally needed, just Delete the contents from the following folder
C:\Users\<<Your Alias>>\AppData\Local\Microsoft\Team Foundation
Do not delete the rest unless necessary, fix the cause not the symptom.
My issue was that the project name had a period '.' in it. Removed it and the change source control Bind was Valid.
I tried all the solution above and none of them worked for me.
But I found a way to force add project. In Visual Studio :
Go to team explorer
Click on Home
Click on Source Control Explorer
Select the directory and click on "Add Items to Folder" (the icon is a file with a little green + in the top left corner)
Add your project files
... problem solved
Is it possible to use NUnit3 Beta in VS2015RC?
I've just created a new Library Project (Package) and added NUnit and created a simple test to show the errors I'm getting.
Does it have some dependency on an older version of the framework?
project.json
Test Class
Update
The Release Notes say:
To work around this issue, follow these steps: Right-click the project
in which the errors are reported in Solution Explorer, and then click
Unload Project. Right-click again on the project in Solution Explorer,
and then click Edit .
Note In this command, represents the actual project
name. In the entry at the top of the project file that
has no Condition attribute, add the following:
true
Save and close the file. Right-click the project name in Solution
Explorer, and then click Reload Project.
However I cannot get this to work, I just get more warnings and errors in my errors window.
It is very likely that you should use xUnit.net for now,
https://github.com/aspnet/Testing/issues/34
NUnit won't be ported unless someone steps in.