I am currently trying to write a plugin for visual studio that accesses the bin folder of the currently open project in Visual studio. However, all the solutions I have come across simply return the bin folder and directory of the plugin that is I am writing. For example, I have used the method detailed in the article below, which claims to return the current project's directory.
How to Access Bin Folder of Active Project using visual studio 2010 add in
path = System.IO.Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
System.Windows.Forms.MessageBox.Show(path);
Is there anything I am missing on how to make this work?
A Visual Studio project can have several project configurations, each one with a different output build folder that is set in the project properties window, Compile/Build section, Build output path. Furthermore, the output build folder can be absolute or relative to the project folder.
The code of this article gets the absolute output build folder for the active configuration of each project of a solution:
HOWTO: Get the output build folder from a Visual Studio add-in or macro
http://www.mztools.com/articles/2009/MZ2009015.aspx
Related
I'm using Visual Studio 2015 update 3 with TFS hosted at visualstudio.com.
When I add a C# class file to one of my projects in Visual Studio, it's not automatically added to source control. For other projects in the same solution, C# class files are added automatically, as expected.
When I then add the file, manually, in the project with this problem, I get the following question;
I have to confirm to add the file to source control.
There is a similar question (Visual Studio 2015 new files not being added to source control automatically), associated with a "release" branch, which is not the case here (at least I think so - our TFS-project has never been branched)
We've never configured any .tfignore manually.
This started to happen recently and occurs on all development machines, so it's probably not a client machine issue.
I'm clueless, so any help is highly appreciated.
UPDATE
I've discovered that the problem occurs in projects with names ending with ".Lib"
Projects:
Core (ok)
Core.Lib (files not added automatically)
Communication (Ok)
Communication.Lib (files not added automatically)
I tried to add a test project Test.Lib to my solution. This project was not added to TFS either, but project Test was.
The "lib" extension is the problem. Try renaming the project folder to something else, eg. "CoreLib".
To reproduce this behavior / bug, try the following:
Create a Test directory in a directory controlled by TFS
Create a Test.Lib subdirectory in this directory.
Add a file, test.cs, to Test.Lib. (Test\Test.Lib\test.cs)
In Visual Studio's Source Control Explorer, try adding the new Test directory to source control. You'll see test.cs on the "Excluded items" tab.
The "lib" extension is used by binary files, and these are ignored by Team Explorer by default. I haven't found an official list of filetypes anywhere, but other affected file types are dll, exe, obj and possibly others. You can include these files manually by right-clicking them and selecting "Include".
I am trying to build a project in Visual Studio 2013. There are no errors with the project but it will not build. There are several other projects in the solution and they are all building and push the DLL to the bin/Debug location just fine. This particular project suddenly does not. Any ideas? I have set Copy Local to true and verified the path for which it is supposed to push the DLL and it is bin\Debug.
Double check the following:
Open the Configuration Manager for the solution, verify that "Build" is checked off for the configuration currently being used.
BuildAction property is set to "Compile" for the source code file(s) in the project (look in the properties window when you have the source file selected in the Solution Explorer)
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!
I have some videofiles in our SVN repository alongside the sourcecode of my application. After checking out, the visual studio project is built using cmake.
my code needs to load the video files and it works well when running the application out of visual studio - but when the exe file in the release/debug folder is doubleclicked, it crashes because the relative paths are not right anymore. aparently when running it from within visual studio, the folder where the .sln file lies is considered the root of relative paths.
how can I refere to the videofiles from the code, such that the application works if i run it within visual studio as well as if i double click the exe in the release/bin folders, without to duplicate the videos? (they are quite big)
I need to do this because I have to hand in my application such that it can be compiled and run out of the box as well as executed without visual studio.
You can change your project's settings to make the IDE's behaviour match double-clicking on the executable, and then fix your relative paths.
For VS10/VS11, in the project's properties page, at the top select All Configurations from the Configuration: list.
Then select Configuration Properties->Debugging and set the Working Directory to $(OutDir)
Beware that running the executable from the command prompt in a directory other than $(OutDir) will still fail.
I wrote a C# windows service project and a related setup project in the same solution named MailTrigger. But after I built the whole program, there is two folders, "MailTrigger" and "MailTriggerSetup"(as I named the setup project). My problem is how can I set the two project to be in the same folder?
When you have a solution, you will have individual project directories under your solution directory. You have the ability with the setup project to tell it where to put the created binaries. I am not sure what specifically you are wanting, all of the files in one folder without any delineation between your main project and your setup?(which will not work) or just wanting your msi files in the same folder as your main projects code?
Edit: I was able to get a directory structure that looks like:
By moving the MailTriggerSetup Directory into the MailTrigger Directory and editing the MailTrigger.sln file's project settings with notepad to look like this, also just change the file paths not the Guid's :
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MailTrigger", "MailTrigger\MailTrigger.csproj", "{FD22977F-584D-4707-9B10-35482B91C450}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "MailTriggerSetup", "MailTrigger\MailTriggerSetup\MailTriggerSetup.vdproj", "{15C4C96E-EF6A-44DB- BDFB-8AEE2C05289E}"
EndProject
Some caution needs to be taken since you are directly editing the solution file, Please backup your data before trying this.