I am trying to add Microsoft.CSharp and other system references to a c# class library in vs 2015 community edition bound to tfs. when i add it doesn't persist the path for this particular class library. All the references i add are highlighted in yellow !. The same references and paths I am able to add to other projects but not this current one I am facing an issue with.
I have created a new solution and tried. it still doesn't work.
However I would not want to create a new project file. Any suggestions or workarounds to solve this problem?
Your .csproj files might be "corrupted" somehow. I would create a new project file and then overwrite your existing project file so that it can be checked into TFS.
Create a new project and copy all of your source files into the folder. If you have folders use Visual Studio to re-create them. Use the show hidden button in Solution Explorer to show all the files. Now include the files by right clicking and selecting include in project (you can use Shift to select multiple files). Check your project properties and make sure you copy anything important.
I tried a few things-
I changed from community edition to professional edition 2015. the same problem persisted.
I created a new csproj file and added back the files manually. It got added fine.
However I am pulling the references from a nuget packages folder and updating. if we have the wrong path to the nuget packages, even though we add the references, they were being shown as not referenced.
The nuget packages needed to be correctly mapped or else VS2K15 acts weird.
So bottom line, because my nuget references were incorrect it was throwing these errors. I know This is very weird!!!
Related
I cloned my project from the github repository.Now i made a new folder in this project and added here a class with a namespace.However, when i tried to add a using command with this namespace(c#) to another class(this class was in my project from the start, because it was in git repo), I noticed that project doesn't see this Folder/Class/Namespace.I don't really know what can I do so I'll be very grateful if you will help me(VS 2019)
Try to open the project file (unload the project and edit proj file)
Check if the Folder is in there.
If not, you can manually insert it and reload the project.
Oh and in case that you reference to another project, check if the newer projects framework version is not over the referencing project.
This could also be a possible error.
I know it's quite old topic, but I've got the same issue today. And the reason was that I created repo with a name containing space, like "My repo".
In the link generated by git, repo name was "My%20repo". And the same directory was created on my local machine (os: win 10).
It appears that VS can't treat "My%20repo" as valid directory name, and no directory nor file has been added to project on creation. Strange thing is, any file or directory created later has been perfectly visible.
So I've just changed directory name to get rid of this "%20" part, now it works just as supposed.
Not sure if that's true reason. But that's my experience I wanted to share :)
Follow this link, may be it could help:
visual-studio-2019-doesnt-include-on-csproj-new-files
This solve the issue: update the package Microsoft.Net.Compiler to the latest version, compile and try adding a new class to your project again.
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
All .cs file in my Xamarin project are Miscellaneous files http://prntscr.com/cp3q4w . I have no Quick Actions and Refactorings support, and it seems like there is somehow missing reference to Xamarin.Forms http://prntscr.com/cp3qzr ,but i dont get compile error for not recognizing xamarin components.
This is Xamarin.Forms Shared project.
Tried with this solution:
i) Clear the cache
ii) Open the solution
iii) Unload all projects
iv) Load Android project and then fix nuget references
v) Once the references were fixed, I loaded the shared project. Now everything seems to work.
But, didn't succeed.
Anyone had similar problem? Any suggestions for solution?
Thanks.
First thing to try if your solution is checked in to source control:
Do a full Git clean to make sure there are no left over files stopping compilation
Clear your NuGet cache. (How to clear NuGet package cache using command line?)
Try again.
If this fails, try this:
Starting a new Visual C# -> Cross Platform -> Mobile App (Xamarin.Forms) solution in Visual Studio 2017. I recommend trying a ".NET Standard" project rather than a "Shared Project".
Make sure the solution compiles and runs to make sure you have all the necessary components for Xamarin Installed.
Do a back up of this clean solution, or commit it to source control.
Upgrade all the NuGet packages if necessary
Pull all the files in from your old solution and see if you get the same problem. Just remember to make sure that the files are added as the correct type of file. For example xaml files must be set to "Embedded resource".
If you still have trouble, please post the error that you get, and upload your solution somewhere so we can have a look.
This also happened to me.
It still does every now and again.
These steps work for me:
Close your solution.
Delete the packages folder from your solution folder or just rename it to packages.old
Open your solution and restore the NuGet packages.
The new class will now show up correctly and your intellisense should work again.
Does anyone have an idea what could cause this though as I don't see any errors when building?
I'm trying to create a Monogame Project in Visual Studio 2012. Monogame itself is installed correctly, I've cloned one of my older projects from github and it compiles fine.
But if I create a new project in Visual Studio the .dll references are wrong. There is a build error that complains about not finding SDL.dll . There is the SDL.dll reference in my project outline and it indeed points to the wrong file:
This path "C:\Users\lhk\Program Files..." does not exist. Windows doesn't store Program files in its "Users" folder.
I opened the explorer and opened the very same path without "Users\lhk\" and the .dll is found.
Then I checked my older project again. The same SDL.dll is referenced in the Visual Studio solution but the path is the correct one. And the older project compiles just fine.
Somehow the Monogame Project template fills in the wrong paths.
Now here's the problem:
I can't edit that reference.
The text is greyed out and not editable and I didn't find the correct settings to change the reference.
Oh, the problem is solved:
I tried drag-and-drop with the dll.
So far Visal Studio always complained that there is an existing file with the same name.
I tried to "cut" the wrong .dll but that only made its icon slightly transparent. The new .dll still couldn't be added.
Turns out that the ENTF key can do what cutting can't.
I'm afraid I never got the idea that I could delete it with ENTF after cutting didn't work. Now its gone.
I dragged the new dll over to the project.
Compiles fine
Apparently you can just drag and drop references to a project.
At first I thought this wouldn't be possible because the wrong .dll just couldn't be deleted. I tried to "cut" it from the project but it just changed the color of its icon and persisted.
With the old .dll still intact the new one couldn't be added.
I'm afraid the solution is extremely simple. You can just remove this reference by pressing "ENTF" - it's rather embarrassing. But I never thought this would work after cutting had no effect.
With the old reference having been removed you can indeed drag and drop the new one.
The project compiles fine.
What I did is create a path on the drive and put the sdl.dll file there. So whenever I make a project Visual Studio finds it.
SOLVED! For people who are having the same problem this is what i did:
I moved the project away from where Visual Studio though it would be. This forces you to create a new project file there. I did. Then i restarted the program and now my project was visible. I now just moved the original project-files into the now visible folder.
I added an project to my solution but it doesn't show up next to all the other imported projects.
And since it doesn't i'm unable to delete it and try again.
However it can be seen if i right click the solution and go to "Startup Project", "Project Dependencies" or "Debug Source File".
I have searched the web for a while now but have yet to find someone with a similar sutiation, how do i solve this?
I imagine that this is because the files don't exist. Have you created the project on a network drive somewhere? Have you renamed or moved the folder after adding it to the solution?
Check the paths are right, then double check. Also check your version control to ensure someone hasn't wiped out your changes and left the .sln file intact.
You can edit the .sln directly I suspect to double-check the exact path it's looking for. Verify that path exists too.
Make sure the project you added was created in the same version of Visual Studio too.