Visual Studio can't "find all references", but can "find in files" - visual-studio-2019

Visual Studio 2019 Pro, v. 16.11.13.
A Solution with about 100 projects. All projects are included in the build process. Solution was opened about a half an hour ago, and was just fully rebuilt.
I'm clicking on some const field and choose "Find All References" - nothing was found, except the "Symbols without references". Then I'm trying to find this field through "Find in Files", and it found me a reference to this field inside some Razor page. Checked - there are no broken references. The project, that references to this field, has reference to the project, that contains this field.
But! After opening the Razor page with this field, now it can find this field through "Find All References".
What? Why? For what reason?

Related

Adding Javascript file to MVC Project in VS 2022

I have migrated my project from VS 2017 to VS 2022,
And I have a strange problem:
When attempting to add a new .JS file to the scripts folder
I don't have the option to select .JS file in the "Add New Item" menu (via right-click on scripts folder), only .TS or .JSON:
Tried "playing" with it and searching but did not find any solution.
can someone please tell me what am I missing?
This depends on one thing that is if you installed all required modules for Visual Studio 2022.
The basic thing here is to Right-Click on any directory/folder in the Solution Explorer window, Select Add and then New Item. You then click on the Language you are programming in. Note: if you don't click this folder, the options you may see would be only for the selected folder.
See below images...

VS 2019 - How to choose location for Add new project

For a VS 2017 solution, when you right click on solution and choose add new project, in the templates page there is an option to choose the destination folder (if different from the solution folder), however it does not seem to be an option in VS 2019 preview. Is there anyway to have that option show up ? (is it even an option in 2019 ?)
To clarify - this is when you already have a solution open and are trying to add a new project to that solution
Apparently, it was an issue with Resharper as well which messed up the new project dialog windows. Once that patch was installed everything worked as expected throughout. Odd issue and an even more odd fix.
https://youtrack.jetbrains.com/issue/RSRP-473453
I have VS2019 preview installed.
From the start page select 'Create a new project', then select a project type. For example 'Class Library (.net Core)and press the next button. The next screen will present you with textboxes forProject name,location,solution name` and an option to place the solution and project in the same directory

Certain Razor views not publishing

Using VS 2017 with MVC 5 Razor views. When I publish my application, a handful of specific views do not get copied over.
I'd discovered several SE questions on this same issue from back in the 2010-2011 timeframe. At the time, the issue was that Build Action in the file's properties was not set to Content due to a bug in some early RC which has since been resolved. Well, all of mine already do day Content for Build Action.
Any reason why only a small number of views are not making it in the publish?
As far as I'm aware, there are only 2 things that can cause this to happen.
As you say in the question, the build action for each view needs to be set to "Content"
The view files need to be included in the project file, so in the .csproj file there should be a line like this:
<Content Include="Views\ControllerName\Index.cshtml" />
Another one would be to set this in your csproje file. This was missing in mine, which caused it to make a precompiledviews.dll in my publish:
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
Set it to false explicitely in order to publish .cshtml files.
Visual Studio -> Right click on "Views" in solution explorer. Click "Publish Views". This will set all the views to Content"
Depending on the version of Visual Studio, excluding and then including partial view or its folder may work or not. The most certain way to do it is to remove it from .csproj file and then include it again.
lets say _LoginPartial is not updated after publishing (especially if you have some razor code).
First open '.csproj' file, and remove
<Content Include="Views\Shared\_LoginPartial.cshtml" />
The build the project, and then add it again to .csproj, and rebuild and publish.
Another Solution From Visual Studio
right-click on the file and "Exclude From Project".
select the Project and click on "Show All Files" from Solution Explore (top horizontal menu bar on Solution Explore)
right-click on the file that Excluded and Click on "Include In Project".
This will automatically modify the .csproj file.

TFS: Restore deleted folders and items

I deleted some files and some folders in TFS. Many check in's later I found out that I need the deleted functionality back in my project.
How can I restore the deleted files and folders?
In Team Explorer (in Visual Studio): Tools | Options | Source Control | Visual Studio Team Foundation Server and select Show Deleted Items...
Then in source control explorer you'll see the items greyed out. You can right click on them and Undelete. (This option will only be available if they, after the undelete, will be included in your current workspace).
NB. in newer versions of Visual Studio (eg. 2013) there is now a button to switch on display of deleted items in the Source Control Explorer's toolbar. Its the second button (here with the VS dark theme):
Alternatively using the TFS PowerToys you can look at history and right click to select "Rollback Entire Changeset": this will create pending changes to revert the changes of the selected changeset.
Edit: Added paragraph on newer versions of VS.
Assuming you successfully undelete as per #Richard's answer, there might still be an issue with the item appearing in Solution Explorer (at least it was for me using Visual Studio 2015). That is to say, the file is restored on your hard drive, in the proper place in your project's folder structure--but it's not showing in VS.
To resolve this, click the Show All Files button in Solution Explorer:
You will see your file, in a ghostly white icon. Right-click on it and select "Include in project". Save and check-in changes. You are back in business.
Recently I faced this issue, accidentally I deleted some classes which weren't checked in, I searched the name of the classes in my project directory (I was working on D365 project there is a bin folder in C:\AOSService\PackagesLocalDirectory\bin\XppSource) and saw that in the bin folder they were existed so I created new classes with the same name and copy the logic.
Also I should mention that no file was in recycle bin.

_PublishedWebsites dont include webfonts?

I am a bit baffled, I have an MVC3 project in Visual Studio 2010, and as part of our build script which outputs the compilation to an "output" directory.
This all works fine, however we are now using webfonts as part of our site and no matter what I try, the webfonts never find their way to the _PublishedWebsites folder, even with Copy To Output Directory just puts it in the general output folder not the _PublishedWebsites one...
So am I missing something?
Had the same problem too. When your project is open, select all the webfont files in Solution Explorer. Right click on any, and select "Properties" from a context menu. In the collective properties dialog that will appear, set "Build Action" to "Content". This will tell the package assembler to treat these files as content indeed.

Resources