I'm using visual studio to create a game using the SDL library. I've also created my own static library that my game relies on. (It's the basic engine that sets up sdl, maps, ect.). Now when I include one of the files from my custom library, I have to type it like this:
#include <SDL_Game_Engine/Files/whatever.h>
Obviously that can be a bit tedious in typing all that.
So what I'm wondering is if there's a way in properties that will allow me to type
#include <Engine/whatever.h>
(Basically take the whole path to the file and make a shortcut for it).
I know it's a long shot but it would be awesome if there is a way. I don't like to have my include directory to include up to the files directory that way I know that the file I'm using is in my SDL_Game_Engine library. Is this even possible (with my luck there's no way lol) but any suggestions would be awesome. Thanks guys!
PS. Using Visual Studio 2015
Not sure what the SDL library is but..perhaps you can place things in an app.config and then assign a variables to your path;
String filePath = ConfigurationManager.AppSettings["YourFilePathKeyInAppConfig"];
then use it in code:
someGameVarFile = filePath; //psuedo code
Related
I'm looking into Visual Studio 2019 Class Designer to draw a diagram including mulitple classes in a package. I've noticed the only export format is Image and the .cd xml format contains absolute paths to the c++ class header files.
I've attempted to manually tweak the paths so they are relative and I now when I open a .cd file I get this:
I did sucessully move a .cd file from one computer to another by replacing the absolute paths prefixes, but it felt like a hacky workaround. I was hoping I can simply use relative paths.
Is there way to tweak the .xml so it's editable again ?
(I've tried undoing the changes, but that didn't solve the problem and I'm suspecting the UUIDs might have something to do with it, maybe?)
What's the recommended way of sharing a Visual Studio C++ class diagram for editing within a team ?
In my experience using relative paths isn't supported and (even absolute paths barely).
The only workaround I could think of is using a script to run wihin Visual Studio to run before openning the diagram on a new machine to detect the source code folder and alter the absolute paths accordingly.
In practice, this would be a nightmare under version control and using a completely separate diagramming tool and manually drawing the diagram is unfortunately the reality of the situation.
(I look forward to an alternative tool that can easily generate a class diagram that can be shared/edited within a team).
What I like to do is compile a custom file to generate a C# file. I only need it to compile when its been changed but compiling everytime is ok.
When I looked around I kept finding reference to Custom Tool and found this pretty good article. I remember pre2010 I was able to have a build rule for extensions but it looks like that doesn't exist anymore? It allowed me to specify an extension and bin+args to run against when the file changed. Whats the closest thing to that? It looks like it no longer supported which is exactly what I want
Custom Tool requires me to mess around with registry, create a dll and requires VS SDK. Its way overkill for something I done with ease in the past.
How do I have visual studios run my exe to build a custom extension source file without going into overkill like custom tool above? Must work for C# project, C++ projects would be nice but not required.
I am making changes to a Visual Studio wizard that creates a project from a template, and needs to add a reference to an assembly to the project that also lives in the extension directory. So I need to set the <hintpath>.
I have not been able to figure out how a running VS extension can discover its extension directory, which is a directory name like this:
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\myCompany\myExtension
Using System.Reflection.Assembly.GetExecutingAssembly().CodeBase yields:
"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\myCompany.myExtension\v4.0_1.0.0.0__936015a19c3638eb\myCompany.myExtension.dll"
Unfortunately, not helpful. Using GetCallingAssembly() is no better--it points at another directory in the MSIL_GAC.
Is there a Visual Studio interface that returns this information? I haven't been able to find it.
If that's not possible, is it at least possible to determine if the extension is running in the experimental instance vs. non-experimental? I could use that information to locate the extension directory.
Maybe look at IInstalledExtension.InstallPath. You can get an IInstalledExtension via an IVsExtensionManager.
Unfortunately, the message in the remarks suggests this is not the right way to do things:
Although this API supports the Extension Manager infrastructure, we recommend that you do not use it because it is subject to change.
EDIT: Here's the code:
static IVsExtensionManager GetExtensionManager()
{
return myPackage.GetService(System.typeof(IVsExtensionManager)) as IVsExtensionManager;
}
static IInstalledExtension GetExtension(string identifier)
{
return GetExtensionManager().GetInstalledExtension(identifier);
}
static string GetExtensionDirectory(string identifier)
{
return GetExtension(identifier).InstallPath;
}
The string identifier is whatever you put in the "ID" field of your extension's source.extension.vsixmanifest file. It defaults to the package GUID.
Sorry for digging up an old answered question...
I was looking into a similar problem, and have implemented the Extension Manager, but decided this is just pretty awful, though if you do want to do use it these links will also help:
https://stackoverflow.com/a/24294185
http://blog.ninlabs.com/2011/04/auto-update-visual-studio-extensions/
However, I decided to look into how the CodeGenerator in Asp.Net.Scaffolding accessed template files. Turns out, very easily...
var path = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "MyPath");
Simples
I am trying to create empty solution file for Visual studio 2010 but I am unable to do so?
We used to create empty solution file for vs2008 by
EnvDTE::_SolutionPtr ptrSoln(_T("VisualStudio.Solution.9.0")); but I am unable to find equivalent for VS2010.
I was able to find how to create project but not Solutions?
I found the answer. Answer lies in previous question mentioned by me - How can I create new blank solution in vs 2008 programmatically?
I forgot to add reference to EnvDTE, EnvDTE80. EnvDTE90 and EnvDTE100 assembly. Also name of solution class is Solution4 instead of Solution3. So code snippet which works is:
string visualStudioProgID = "VisualStudio.Solution.10.0";
Type solutionObjectType = System.Type.GetTypeFromProgID(visualStudioProgID, true);
object obj = System.Activator.CreateInstance(solutionObjectType, true);
Solution4 solutionObject = (Solution4)obj;
solutionObject.Create("C:/", "Test");
solutionObject.SaveAs(#"C:/Test.sln");
Not 100% sure what you're asking. If you just want an empty solution with some pre-created folders, which would be a file just named yourProject.sln, go to whatever primary language you have installed (C++ in my case), and make an empty project. This will give you an empty solution file, with just one folder, it would be named yourProject in my case above, and a few project files related to the language. If you want to add a new project to this solution, go to:
File->Add->New Project. Fill in the rest with whatever application type your project/program needs to be. This is how it's done in C++, I don't know how to do it in, say C#. However, you didn't specify a language... So I'm not sure where to go to help you, Visual Basic? C++?
So we have this tool, it's a web page, we drop a large piece of text in textBox a (say sql) run the tool
and it generates the guts of a code file in TextBoxb (say a custom view class model).
it's written in C#.
I know there are several ways to create visual studio extensions.
What I'd like to know is, what's the best/easiest/fastest way to take a c# dll that has a method that takes text in and returns text out, and turn it into a VisualStudio extenson, that takes text in and creates a files, adds it to the project and puts the text into it.
We're using Vs2008 and VS2010, and I'm okay the best soloution only work on 2010.
The closest I've found by googling so far is this:
http://visualstudiomagazine.com/articles/2009/03/01/generate-code-from-custom-file-formats.aspx
but they are for custom file formats only, i want to generate*.cs and *.rdlc and similar files.
I'd also like to be able to add methods to an existing class.
tutorial walkthroughs or better approaches woud be greatly appreicated.
VS package Builder is the answer. Lots easier.