How to get currently running project from Visual Studio extension - c#

I am trying to create a VS extension and I need to know the currently executing project (for example, if someone is building a Xamarin.Android app and they have deployed it, I need the Xamarin.Android project). Further, I need to know the output directory of that project (so I can get some binaries from it). Can anyone help me with this?
I've tried using IVsSolution, and DTE2 (among other related things), but haven't found anything that tells me what is currently running.
Thanks

To know the output build folder of a project using automation (EnvDTE.Project), see:
HOWTO: Get the output build folder from a Visual Studio add-in or macro
To get the solution startup projects using automation see:
DTE.Solution.SolutionBuild.StartupProjects
Native VS services are somewhat more limited in this area than automation:
IVsSolutionBuildManager.get_StartupProject
The EnvDTE.Debugger object has properties to get the active process, etc:
Debugger Interface

Related

How to get visual studio debugger to completely ignore original source file location

I'm beginning the work of moving an internal class library (.net framework, C#) to a series of nuget .net standard packages, which we will also serve internally. I'm in the research phase.
And I am attempting to research using the VS (2017) debugger and working to create our conventions for where debug versions of the packages (with symbols) will be and where the release versions (without symbols) will be.
I build a small dummy .net standard package in one solution, and have used nuget add to place it in a file share. And I have successfully consumed it in a different solution.
However, when I try to step into the code in the consuming solution, somehow, visual studio is doing something smart and actually stepping me into the source at its ORIGINAL location. Which is fine in some ways of thinking about it, but I want to simulate the situation of a different developer on a different machine consuming the package and not having that original source available, such that the only way to step into packaged code would be to consume a debug version with symbols. But visual studio is foiling me by figuring out the original source location and I don't see how it is doing that.
How can I get VS to be "dumber" so I can simulate on my machine what it would be to consume packages on another machine that didn't have this package source?
Thanks in advance.
How can I get VS to be "dumber" so I can simulate on my machine what it would be to consume packages on another machine that didn't have this package source?
You can try to specify the Symbols of that .net standard project to exclude from automatic loading.
Detail:
As we know:
The Program database (.pdb) files, also called symbol files, map
identifiers and statements in your project's source code to
corresponding identifiers and instructions in compiled apps.
Symbol files also show the location of the source files, and
optionally, the server to retrieve them from.
And the default setting of symbols loading for debugging in Visual Studio is that Load all modules:
That is the reason why Visual Studio smart and actually stepping your into the source at its ORIGINAL location.
So, to resolve this issue, we need to disable Visual Studio "Load all modules", we could specify excluded modules for your .net standard project.
To accomplish this, click the link on that window, then add the name of your .net standard:
Then Visual Studio get to be "dumber", not find the ORIGINAL location.
Hope this helps.

How to open C# Solution

I am relatively new to programming and only have some experience with Python and MATLAB but was given an assignment in which I have to run and test a sample program using .NET. I'm set up with Windows 7 via VMWare running on my Macbook Pro and obviously I've got Visual Studio on the desktop.
I have a zip file of the sample program but am having trouble opening it correctly in Visual Studio. Inside the file there is a Microsoft Visual Studio Solution with the same name as the test program. When I open that I get error messages saying certain file paths are not found (which I assume means that I'm not opening the program correctly).
There are also:
a couple XML configuration files
a Visual C# Project File
Visual C# Source files
other folders entitled 'bin', 'obj', 'Properties'
Again, I know this might be a very rudimentary solution but I have been struggling with it for a few days and was hoping I might be able to find a solution here. Thanks!
If you have extracted it correctly, by double clicking on .sln file should launch the application on visual studio.
You can create new solution and import files and references.

create exe from visual studio 2012 c#

I made a little app with c# which I wanted to send to a friend to get an opinion. Problem is when I selected release configuration and click rebuild I get 7 additional files(3 dll's, 1 exes,...) along with the exe I want. Am I doing something wrong? I used to get single .exe files back when I used c++ with VS 2005.
You are not doing anything wrong. Its just that at release additional files are generated like AppConfig.xml for instange that holds your application settings, or a ClickOnce deployment package so that your friend can install the app. To get more used to c# you can start by googling articles about the differences between debug and release
Have you considered using the Click Once facility built into Visual Studio 2012?
Click Once Deployment - MSDN
Click Once will generate an installer that will that your friend can execute. It will automatcially download and install any dependencies (such as a specific .NET Runtime) if necessary.
To distribute referenced DLLs look at the following URL as it suggests the correct configuration settings:
How to: Specify Which Files Are Published by ClickOnce
It's been an horrible hour. Couldn't get Clickonce working for such a simple app. Moving just the 3 referenced dlls and the exe to another folder worked. Wix on the other hand...is difficult to say the least.
However, this allowed me to create a single setup file if not an exe in 10 mins. I sent a shortcut to the desktop which is more or less what I want.

Skip DLL files in .NET setup project

everyone, I am having a question or problem when building a setup project for an add-in (both are developed in c#). The add-in is used for a big software, and it needs a DLL from the software. If I just build the add-in and use it, it is fine. But if I install it using a setup project, the DLL provided by the software should also be copied to make the add-in work. But since if the client who uses the software, has already the DLL (coming along with the software), so I wanted to skip this DLL, so exclude it from the setup. But if I do so, I will get error 1001 when installing the add-in, saying at least one type from the assembly (the add-in) cannot be loaded. If I include everything (all the dependencies), it works.
So does anyone have idea about this? How can I skip the already available DLL that comes along with the software?
you can use web deployment project to build your application instead of the default publish in visual studio and before building it right click on the WDP and select Open Project File:
inside the .wdproj file search for item group <ItemGroup></ItemGroup> tag and add the following
<ExcludeFromBuild Include=”$(SourceWebPhysicalPath)\FolderName\**\*.*” />

How do I set the flags/switches for the aspnet_compiler in Visual Studio 2010?

I'm having some trouble with namespacing for a web application project - front-end files are being compiled into separate assemblies under the ASPX.directory1_director2_directoryn_filename namespace format and I want everything in one dll.
I found this question and setting the -o flag would appear to be exactly the solution I'm looking for. However I build my code in VS2010 using the standard Build menu option and I can't find anywhere I can set it. Can anyone point me in the right direction?
I suppose you meant aspnet_compiler. Here is a tutorial. It's related to Visual Web Developer 2008. But the basic idea is the same - use the External Tools dialog to create you desired action.
If you're using a Web Site Project, the ASP.NET compiler options can be used from the Publish dialog. For a Web Application Project, you can use Web Deployment Projects to enable pre-compilation (technically, WDP should work for WebSites as well).

Categories