Show only excluded files in VS2010 - visual-studio

Is there any way (plugins / extensions are perfectly fine) to show ONLY items that are excluded from a project / solution?
I have a project in which I've just done some significant refactoring and several files and folders are no longer needed. Now I want to remove them from source control (Mercurial, VisualHG plugin is installed in VS2010). It's a rather large solution so I'd rather not have to manually drill through Solution Explorer to find them.
Or, if someone has another process to do this I'm certainly open to that as well.

Theres no existing addon at the moment. As the project files are XML (see below), in theory you could write an app to parse it and then compare it to the contents of the project directory; and enumerate each one gathering a list of items that are not included.
<ItemGroup>
<Content Include="rootFile.html" />
<Content Include="Directory1\File1.xml" />
<Content Include="Directory2\File2.xml" />
<ItemGroup>
As for integrating this behaviour into Visual Studio, either file a feature request with Microsoft or write this addon.

Related

Preventing Visual Studio from rewriting project references

I have a large solution in which the "root" project includes feature projects by glob:
<ProjectReference Include="..\Feature\*\*.csproj" />
This works, despite not looking great in the references list, but the issue that occasionally Visual Studio will rewrite the csproj with all of the project references resolved:
<ProjectReference Include="..\Feature\A\A.csproj" />
<ProjectReference Include="..\Feature\B\B.csproj" />
It's not clear what triggers this, but I'm guessing it might have something to do with NuGet.
Is there anyway to stop VS from doing this (akin to using DisableFastUpToDateCheck for custom MSBuild scenarios)?
It's not clear what triggers this, but I'm guessing it might have something to do with NuGet.
It should be related to the items in the ItemGroup. I have the similar issue before, but the difference is that I use wildcards to contain .cs files and your are .csproj files, looks like:
<ItemGroup>
<Compile Include="**\*.cs" />
</ItemGroup>
When I delete one of .cs file in the <ItemGroup>, the wildcard gets expanded in the csproj file. For you case, if I deleted the the C.csproj project from Visual Studio (Add it before, reload the root project), then I got the same result as you.
For this issue, many other community members submit a user voice to Visual Studio team: VS IDE should support file patterns in project files. Now this is well supported in the new project system used by .NET Core and .NET Standard in Visual Studio 2017, but they haven't done the work to support it for existing project types.
Is there anyway to stop VS from doing this (akin to using DisableFastUpToDateCheck for custom MSBuild scenarios)?
To resolve this issue, you can use option Exclude="..." to exclude the project that you do not want to refer to:
<ItemGroup>
<ProjectReference Include="..\Feature\*\*.csproj" Exclude="..\Feature\C\C.csproj" />
</ItemGroup>
Or, if you want to delete one of project and keep the wildcard pattern, you only need to unload the root project, then delete the reference project, reload the root project, the wildcard pattern would be preserved.
Hope this helps.
I've done further research on this.
For testing, you can consistency reproduce the expansion by renaming any project that's included in the wildcard pattern.
Also, the easiest way to prevent the expansion is to:
Move the project reference globs into Directory.Build.props or another external file
Set DisableFastUpToDateCheck to true in your csproj
Using properties doesn't work and isn't required, likewise with using an Exclude.

How to convert a non-core csproj to VS2017 format [duplicate]

This question already has answers here:
How to upgrade csproj files with VS2017
(6 answers)
Closed 3 years ago.
I have two projects in VS2015
One .NET Core (project.json, xproj)
One regular .NET csproj
When I open project 1 with VS2017, it nicely migrates to the new csproj format.
Project 2 works in VS2017, but I like to convert/migrate/update this csproj to the new project file format to benefit from the new csproj features (multi target, no large file list, readable csproj, NuSpec info in csproj etc)
How could I do that? I cannot find an option in VS2017 for that.
Using: VS2017 RTM
It may be worth your time to look at these. It looks like it can't be done for more complex project types but console and libraries appear to be upgradable
http://www.natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade/
https://github.com/NickCraver/PerfBenchmarks/commit/53c3013b1774056363dcab867bceb1b89ce9592c
And regarding the addition of the more complex sdk types you can watch this github issue.
https://github.com/dotnet/sdk/issues/491
There isn't an option built into VS because the cleaner csproj is primarily for .NET Core projects. It does not fully work with all other project types without some effort and futher customizations in the project file. For example, wiring up things like code generators or nesting in Winforms or WPF apps may not work out of the box for a new SDK-style (new style) .csproj. These can usually be worked around by updating metadata as needed:
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
Note that the Update attribute is key here - you don't want to include the file a second time in the ItemGroup, you just want to update its existing (or lacking) metadata.
There are also some caveats for some project types where targets do not get imported as expected in an SDK-based csproj vs and old one. This depends on how your targets are authored, but one example of this is building VSIX projects (VS extensions) using the VSSDK is really hard to get right in an SDK-based project.
If you want to try the conversion, Nate McMaster's blog post is an excellent resource. He covers both starting from scratch and converting the file in situ. I've found that most of the time it goes pretty smoothly to start with a new clean .csproj and add in any workaround needed.
It's also worth pointing out that a lot of the crap in your normal csproj file is just generated content, and a little hand-editing can go a long way towards cleaning it up. Using globbing patterns, for example, can save hundreds of lines in a large project file. This is part of how SDK-based projects work anyways - they just do the globs in the SDK, so it doesn't show up in the .csproj, but it works nearly the same. For example, if you want to include all the C# files under a folder (recursively), you can do something like this:
<ItemGroup>
<!-- Include all C# files under the SampleFolder and any child folders -->
<Compile Include="SampleFolder\**\*.cs" />
<!-- Include all C# files under this project's root: -->
<Compile Include="**\*.cs" />
<ItemGroup>
The ** matches any recursive folder path.
There are some differences in Visual Studio behavior, because the new project system for SDK-based projects works very different than the old .csproj project system. For example, SDK-projects will automatically detect when files change on disk and add/remove them in the projects; old-csproj won't update them in VS until the project is reloaded.
If you do use globbing everywhere, you'll run into a similar problem as in SDK-based csproj, where certain files are not hooked up to their code generators or nested correctly. As above, you can use the Update= attribute to fix up specific files (or even more specific globs) to get the metadata back to the same.

Sync files/directory automatically to Visual Studio project

I'm trying to automatically add an entire folder structure to a VS C++ makefile project. This isn't to make the project build (it'll always build from the scons file), I mostly want to use VS to edit the code/find in projects/intellisense etc.
I've tried the solutions suggested here : Is there a way to automatically include content files into asp.net project file? My project currently includes the tags
<ItemGroup>
<Content Include="$([System.IO.Directory]::GetFiles('$(ProjectDir)..\', '*.cpp', SearchOption.AllDirectories))" />
<Content Include="R:\src\FabricEngine\FabricUI\**\*.*" />
</ItemGroup>
But I haven't had any success - none of the suggestions give me the list of files in Visual Studio. Is this an MSBuild feature that isn't supported by VS perhaps? Or is it limited to managed products? Any suggestions on how to get this working?
Got similar problem and found that used following worked for me:
<None Include="$([System.IO.Directory]::GetFiles('$(MSBuildProjectDirectory)', '*.cpp', SearchOption.AllDirectories))" />
But issue with this is it just takes really long time and crashes if you have lot of files

How to bypass Visual Studio's F# project folder limitations on Xamarin.Android?

I've created a new Xamarin.Android app and added a few assets to it. Those assets are available in multiple resolutions, so I placed them in their respective drawable-XXXfolders inside the Resources folder. Doing so resulted in the following error:
The project 'XXXX.fsproj' could not be opened because opening it
would cause a folder to be rendered multiple times in the solution
explorer. One such problematic item is 'Resource\drawable-hdpi\pencil.png'
This is being caused by F#'s poor folder structure handling. I usually don't need to use folders at all in F# projects, but in this specific case it's necessary because of the way Android deals with resources. The project loads fine in Xamarin Studio, but in Visual Studio it doesn't.
The project is quite big, what means I (and other people as well) will need to add a lot of files, so manual approaches like this one are of no use, for they're too time consuming.
I read the official docs but there's nothing there that states there's a special way to handle adding files on VS or another way to deal with this limitation. My question is: such thing exists? Can I add those files in another way so that I don't need the complex structure on VS? Will I be forced to use C# or Xamarin Studio against my will?
The references to folder files have to be listed together, they can not be interspersed with files in different location. Sort the refs and it will be fine.
EDIT, for clarity:
<ItemGroup>
<Compile Include="folder\file1.fs" />
<Compile Include="file.fs" /> <-- this can't be between the folder files, all folder files have to be listed together
<Compile Include="folder\file2.fs" />
</ItemGroup>
Sadly, the standard Visual Studio integration does not support folders in F# projects.
Your best option is to use the Visual F# PowerTools. This adds some support for folders to F# projects and so it may work good enough to do what you need. If it does not, then Visual F# PowerTools is an open-source project and it always welcomes contributions!
I don't know much about the Xamarin Android project types - but I guess that adding C# project which is just an empty DLL to store the resources would be a reasonable alternative too. (Then you should be able to reference this from F# and load all resources from there.)

Visual Studio Project - Automatically include externally created files?

Is there a nice solution to be able to automatically refresh/include externally created files in the asp.net application project?
The majority of the time I'm programming front end javascript in Sublime Text 2 editor. When integrating with the rest of the team I have to manually make sure that any new files i've created externally are included in the asp.net project.
Is there an automatic option to refresh the files in a particular folder or something?
Thanks
Figured it out!
in the proj files you can edit the itemgroup includes so rather than just including individual files you can use glob patterns. such as
app\**\*.js
<ItemGroup>
<Content Include="app\**\*.js" />
<Content Include="scripts\jquery.js" />
</ItemGroup>

Resources