Visual Studio 2013 - Add New Scripts in /Scripts/ Folder in .csproj - visual-studio

I've begun to really enjoy a quick contextual menu that appears when adding new Typescript files into my Visual Studio Web Project. You can see from this image that I can quickly select that I want to create a typescript file without much fuss. Right clicking all I have to do is go through a folder in Scripts > Add > Typescript File to make said file.
I've begun adding my scripts to another referenced .csproj class library, and unfortunately for me, the context menu doesn't work in the same way. Shown here:
I'm wondering if there is a way to reclaim this menu context without having to convert this project into anything different? Or, if changing the project will have minimal impact on everything else.

Related

Can I create a Visual Studio 2019 project from existing C code?

Here is my current setup:
Some C code (some embedded code) in a folder and subfolders. Organised as I needed and how the embedded editor needed.
If I use Eclipse to create a new C project and place the project file in the root of my sourcecode, then Eclipse will find all folders and files, then index them correctly. I then able to browse the files as a project, functions linked to other files, defines are showing up correctly.
Now, our version control is Visual Studio 2019, and I'm looking for a solution or guide, how to open the same file structure in visual Studio instead of Eclipse. I don't want to open the Eclipse project, I try to drop the use of Eclipse, so I can just use one tool to version control the files and browse the code for editing. I also don't want to compile, debug in visual Studio, I can use the dedicated environment for that. I only want to edit the files like it would be in Eclipse, save the files as the VS editor is much better than the embedded editor. (By the way, the embedded studio IAR and it's editor is horrible, hence why I used Eclipse in the past, but I don't want to open IAR project in VS, just a nice editor needed from VS.)
Any suggestions? Anyone done this successfully?
When you open VS2019 directly (i.e. not via a source or project file) you should be presented with a start page that includes this:
Select "Open a local folder" and it will present the project from the root you select. It will even apply IntelliSense for code completion for symbols within the selected code base. For headers external to the project tree, you can add include search paths to get better navigation, browsing and completion.
A more comprehensive integration with IAR is possible using VisualGDB extension as described here.

Visual Studio 2013: How to copy a project's properties to use in another project?

I tried to copy a project's properties to use in another project as instructed in the stackoverflow question Visual Studio: can I copy a project's properties to use in another project? but it does not work. When I open the created PropertySheet it seems that nothing is copied to it from the original property settings. The above link seems to be for VS 2008 but now I am using 2013. What might be the fault.
Caveat: Tested only on a relatively basic C++ project. But it worked!
Right click on your source project (in the solution explorer)
Unload project
Right click on your destination project and unload that as well.
Right click on each project and Edit {project}.vcxproj. The projects' configuration files can now be edited. (Yes you could also just find the file and edit it directly)
Copy/replace elements from the source to the destination.
Reload both projects. They should reload withut problems.
Tips:
If the reload did not work then copy/replace in pieces instead of the entire project to isolate the problem.
Don't replace the "ItemGroup" and the "Globals" PropertyGroup because these (XML) elements identify the projects in the context of the solution. But you should be able to copy/paste everything below these elements from the source .vcxproj file to the destination one without problems.
Try this on two "empty" projects before proceeding to your magnum opus. And definitely make a backup of your projects before trying this. (you are reading all of this before starting, right? Of course you are...)
This solution works better than others I have seen because it sets and unsets settings completely. It's a total replacement, not just an additive one.

Create Visual Studio Solution from Batch File

Visual Studio seems to consist of a single solution file (*.sln) along with one or more project files (a C# project would have the *.csproj extension).
I have been playing around with a console application that parses existing directory entries to create solution files with the associated project files.
It works, but every time I run into a new project here at work I find myself spending a week or more debugging my console project so that it can churn out a solution for that particular work project.
Is there something out there already that can create a VS solution out of an existing file structure?
As you can tell from my screen capture below, these projects are nested very deep, so it would take a very long time to do this with the apps folder below with the "by mouse" technique in the Visual Studio IDE.
I created the custom console application that is posted in this post:
https://stackoverflow.com/a/22153536/153923
I invite others to contribute how they approached this solution, though.
So, I found out today that this feature already exists in Visual Studio.
Link 1: How to: Create a Project from Existing Code Files
Link 2: How to: Create a Project from Existing Code Files
Basically, though, it says this (just in case the MSDN links get changed or deleted):
You can create a Visual Studio project from an existing app—for example, an app that you obtained from an online source. Project and solution files are created on your computer and the other relevant files are added. A project can be created from Visual C++, Visual Basic, or Visual C# code files.
Security note Security Note
We recommend that you determine the trustworthiness of existing code files before you import them into Visual Studio, because Visual Studio will execute some of the code in a fully trusted process when you open the newly created project.
To create a project from existing code files
On the menu bar, choose File, New, Project From Existing Code.
The Create New Project from Existing Code Files wizard opens.
Use the wizard to specify the details of the existing code files that will be added to the project and the application that will be created when you build the project.
Another good answer was given by cbp in Visual Studio: Create a web application from existing code:
--
OK I figured it out. It's weird, but the following steps will work:
Open fresh copy of Visual Studio
File->New Project, select Web Application
Use the following settings:
Name: Website (this is the name of the existing folder with the website files in it)
Location: C:\Temp\ (anywhere will do for now)
Solution Name: TheProject (name of the existing project's root folder)
Check "Create directory for solution"
Delete the auto-created Default, Global and Web.config files
Save All and close Visual Studio
In Windows Explorer, copy the new folder on top of the existing folder so that the files are merged.
Double click on the sln file to open Visual Studio again.
Select "Show all files" (at the top of Solution Explorer)
Right click on any files or folders you want to add and select Include in Project.
Great idea!

Create a physical copy of a source file in Visual Studio

In Visual Studio, if I try to copy a file from one project to another (by using Copy and Paste or by dragging the file to the new project while holding the Ctrl key) it creates a reference to the source file in the original location. Is there a way to create a physical copy of the source file and place that in the target project source direction without having to resort to using Windows Explorer to copy the file manually?
It's not pretty, but when I want to do what you're suggesting, I double-click on the file in Visual Studio, which opens it. Then I do a File->Save As, choose the right directory and save it. All from within Visual Studio. This is usually followed by adding the new file to the other project.
Was just doing this and realized I should mention a side-effect. Depending on your source control (in my case, TFS 2010), doing this from within Visual Studio may modify the location of the file in the project. For me, this means making sure that neither the file nor its project have any pending changes, doing the save as, then doing an undo of the change this causes in TFS 2010 (project change, file add and delete).
From http://msdn.microsoft.com/en-us/library/0fb6xxhb.aspx:
If you are working with solution items, Visual C++ projects, or other similar projects, you are always working with links in Solution Explorer. If you are working with Visual Basic projects, Visual C# projects, and other projects, you might be working with links or files.
Essentially, the answer to my question is 'No'. In most cases, I must use Windows Explorer.

How do I use a Visual Studio 2010 Project Template I created

I followed the steps on MSDN for creating a template. I created a new project in VS2010 and then used the File->Export Template... option to create my template. I went through the wizard and everything seemed to make sense. I left the default Output location alone (it was:
...Documents\Visual Studio 2010\My Exported Templates\MyProject.zip)
and I left the Automatically import the template into Visual Studio checked. I can see the exported zip file (and I tried moving a copy to the:
Documents\Visual Studio 2010\Templates\ProjectTemplates\Visual C#
folder. But when I start up a new instance of VS2010 and use File->New Project I don't see my template. I was expecting that in addition to RecentTemplates/ Installed Templates/ Online Templates I might get a new category for User Templates. Failing that I thought it might be under Installed Templates but there is nothing new there. Where is my template supposed to appear? Did I miss a step?
Duh, It was working I just didn't know where to look. I would bring up the new project template and search through all the leaf nodes. Turns out I had to click on the Visual C# root in the tree view (it appears to not be in any of the leafs). This always trips me up in tree views, I never expect the root to have options, let alone be the only place that has an option.
I think you should restart( quit and run again) your visual studio!

Resources