What's the best way to debug a nuget package with its souce code? - nuget-package

I'm using a NuGet package in my project and sometimes I need to debug into the source code.
The NuGet package itself is open sourced on github.com so its source code can be downloaded as well. I can build and generate .dlls on my local computer.
But during my debugging, I can see the function names of the package, and even the file path of the source code (or course it's from someone else's computer), but it's grayed out and I can not double click to go into the source code. I checked the right-click menu, there's no way to load symbols there.
In this case, how can I let visual studio load the debug symbols so I can debug into the package's source code?

My understanding is that you install the specific package in your project, if you want to debug the package in your project, you could add the source file to the solutions Common Properties -> Debug Source Files list.
If you download the source code of the package and open/compile it in your VS, I think you could refer them manually to your previous project, and then debug it directly like add breakpoint or others as general class library project.
Reference:
How to debug using Nuget source code
How to debug into my nuget package deployed from TeamCity?

Related

Embed *.pdb files in managed library with Visual Studio 2022 17.1

The 17.1 update for Visual Studio 2022 recently hit and one of the added functionalities is:
When building managed libraries developers can choose to embed their source files with the debug information (PDB file) that is produced by the build, and even embed the PDB file into the assembly itself. We now surface embedded source as part of Go to Definition if a referenced assembly has embedded source and the PDB is available. This allows you to navigate to the original source files that declare the target symbol. Place your cursor on a symbol and press F12 to navigate to the original source file.
However I can't find anything on how to do that.
Does anyone know?
In addition, if I want to publish a package to NuGet and make it so anyone who adds that package to their solution can debug my package's code, do I only need to embed the PDBs or is something more required?
Turns out it's an option found in project properties:

Opened project in android studio and all packages/symbols are marked as incorrect

I am trying to contribute to my first open source project but after forking and cloning from the repo, all files are marked as an error.
Sample error
This is after selecting a source folder.
Current project source
Under package it says: package name does not correspond to filepath
... but I have this
misnamed packages?
Android studio isn't picking up those libraries.
IME there are 2 ways of importing these (I have only had success with the first):
1) copy the source parallel to your own (ie example.com)
2a) include the jar in a libs folder and tell AS to look out for it. (right click will typically provide a good option that I can't recall)
2b) because Android can struggle (ie I couldn't do it, though inroads may have been made since) with importing jars, you may need to use AAR's (android library packages, Android Archive Library (aar) vs standard jar)
However, because this is an open source project, this should all be handled auto-magically for you via the gradle scripts included in the distro.

Unable to create a blank working bridge.net project via visual studio template

Everytime I try to create a bridge.net new project I get the following error:
Could not add all required packages to the project. The following
packages failed to install from [the user appdata local
folder]\Microsoft\VisualStudio\14\extensions\IJHDC25V.XOU\Packages.
Bridge.1.10.0 : Solution is not opened or not saved. Please ensure you
have an open and saved solution.
Trying to build the project leads to the 'Bridge' namespace missing.
I did the following:
Download the bridge.net .vsix package from
https://visualstudiogallery.msdn.microsoft.com/dca5c80f-a0df-4944-8343-9c905db84757
Run the package
Create a new project -> Bridge.net -> Class Library
Named the project 'Demo'
I verified the folder exists and is populated. I've tried running Visual studio as an administrator and as a standard user.
How do I get a working blank Bridge.net project with the visual studio template?
I realise that this doesn't quite answer precisely the question asked but I don't use the VSIX package to create Bridge.NET projects, I just create a new (standard) class library and then use NuGet to add "Bridge". This adds the Bridge compiler and it adds a "demo.html" file and a basic "bridge.json" config file to get you started. (If you wanted to write a Bridge library and you didn't want the "starter park" items then you can add the NuGet package "Bridge.Min" instead).
The project needs to be saved to disk.
In Visual Studio under Tools / Options / Projects and Solutions tick the Save new projects when created checkbox.
Then create a new project.

How to properly create an Alea GPU project? Errors on "Getting Started" code

I have done the following to create an Alea GPU project in Visual Studio 2012 Professional:
File > New > Project > F# Application
Updated NuGet Package Manager to latest version
Tools > NuGet Package Manager > Console
PM> Install-Package Alea.CUDA
PM> Install-Package Alea.CUDA.IL
Installed license using these instructions: http://quantalea.com/static/app/tutorial%5Cgetting_started%5Cinstall_license.html
Copied the code from here https://github.com/quantalea/AleaGPUTutorial/blob/master/src/fsharp/getting_started/ParallelSquare.fs into my main project file.
Build Solution.
I get the following errors:
The lines numbers and file from the GitHub link above correspond with each other.
I'm new to using Alea GPU, Visual Studio, and F#. I've tried doing what I could with the resources I have available. Although the the Alea GPU website explains what to do (install Alea through NuGet, install license, provides code, etc.) it might be targeted to users who have experience working with Visual Studio. It's also worth mentioning I have CUDA drivers installed on this machine.
I have also followed the instructions on this page, but it seems like it's still under construction: http://quantalea.com/static/app/tutorial%5Cgetting_started%5Ccreate_new_project.html. I'm not using Fody since I won't be using C#.
Thanks for reporting the web site problem. Yes, our document are under constructing. I tried your steps and I figured out how to do it correctly, which I will show you later. The issues you met are mainly because:
You are using VS2012, which by default referencing FSharp 3.0, which is a little out-of-date, we suggest to use FSharp 3.1
You forget to reference other assemblies which is used in the code, such as NUnit and FSharp.Charting
Alea.CUDA.Fody doesn't means to work with C#, it means to do AOT compile on GPU code. It uses Fody plugin to compile GPU code during MSBuild process, so your appliction doesn't need to compile GPU code in runtime.
Now, here are the steps:
Open VS 2012, upgrade nuget plugin, then new F# console application project
Expand "References" in solution explorer, and remove the FSharp.Core reference (since it is FSharp 3.0, we will replace it with new 3.1)
Go to "Package Manager Console", install some nuget packages which is used in the code:
Install-Package FSharp.Core
Install-Package FSharp.Charting
Install-Package NUnit
Now we will install Alea.CUDA.Fody (which will install Alea.CUDA by dependency). But since Fody plugin has to run some powershell script to create an FodyWeavers.xml file to configure Fody usage, and this script doesn't work well with F# project (it works with C# project). The workaround is simple, just click "save all" in VS2012 before you run Install-Package Alea.CUDA.Fody. You will see some red error in the package manager console, that is fine, it is just the Fody plugin's script doesn't work well with F# project. You can safely ignore it. After install Alea.CUDA.Fody, a file FodyWeavers.xml file will be added to your project, there you can configure how you will do the AOT compilation. I suggest you add a setting to show verbose information: <Alea.CUDA Verbose="true"/>
Now you need add some common references, since the package FSharp.Charting uses them. To do that, right click your "References" in solution explorer, and choose "Add Reference...", under "Assemblies" -> "Framework", select these assemblies:
System.Drawing
System.Windows.Forms
System.Windows.Forms.DataVisualization
Now your project is set. Please Change the building configuration to "Release".
Now let's add the source file. First right click Program.fs in solution explorer, and select "Add above" -> "New Item...", select F# source file, name it ParallelSquare.fs
Copy https://github.com/quantalea/AleaGPUTutorial/blob/master/src/fsharp/getting_started/ParallelSquare.fs into that new created file
You need modify one place: https://github.com/quantalea/AleaGPUTutorial/blob/master/src/fsharp/getting_started/ParallelSquare.fs#L139 , change this to WorkerExtension.Launch(worker, <# squareKernel #>) lp dOutputs.Ptr dInputs.Ptr inputs.Length , the reason is, the Launch method is an extension method, which the FSharp compiler in VS 2012 doesn't support it well, so we call that extension method directly (So I suggest you to use VS 2013).
Now in your Program.fs file, call the test in main function: Tutorial.Fs.quickStart.ParallelSquare.squareChart(). and then you can press "F5" to run it.
After this, I suggest you read http://quantalea.com/static/app/manual/compilation-index.html where explains the intallation, the AOT vs JIT compilation, etc.

The "SlowCheetah.Xdt.TransformXml" task could not be loaded from the assembly

After installing Slow Cheeath (v. 2.5.10.3) to two projects in my solution, I am receiving the following error:
"The "SlowCheetah.Xdt.TransformXml" task could not be loaded from the assembly C:\Users
\User\AppData\Local\Microsoft\MSBuild\SlowCheetah\v2.5.10.2\SlowCheetah.Xdt.dll. Could
not load file or assembly 'file:///C:\Users\User\AppData\Local\Microsoft\MSBuild
\SlowCheetah\v2.5.10.2\SlowCheetah.Xdt.dll' or one of its dependencies. The system cannot
find the file specified. Confirm that the <UsingTask> declaration is correct, that the
assembly and all its dependencies are available, and that the task contains a public
class that implements Microsoft.Build.Framework.ITask. ISA.IMPD.FalseAlarm.Web.Portal"
I have removed both projects in their entirety (along with Slow Cheetah), re-installed both projects (along with Slow Cheetah), and Rebuilt the solution to no avail. Can anyone help with this type of error?
In my case the error occured while compiling a web project. The folder
%userprofile%\AppData\Local\Microsoft\MSBuild\SlowCheetah\v2.5.10.2
was empty. All the SlowCheetah components were in SlowCheetah\v1 folder instead. I've copied all files from V1 folder to v2.5.10.2 and everything compiled and transformed fine. To make non web projects compile, I also had to delete V1 folder as suggested by Whoever in this thread.
This was a brand new installation of the SlowCheetah Extension and I did not expect the v1 folder to exist at all. I believe this was a bug in the extension installation for Visual Studio 2012.
delete
AppData\Local\Microsoft\MSBuild\SlowCheetah\v1
I seem to have found to solution to this problem.
Here's what I did:
You need to close Visual Studio, then navigate to:
C:\Users\username\AppData\Local\Microsoft\VisualStudio\11.0\Extensions
Delete the cache file that has the latest date and time
Open Visual Studio and remove Slow Cheetah from the Solution level
Re-install Slow Cheetah from the solution level to the desired projects.
This was failing on our build server, so I changed the revision number from:
<sc-MSBuildLibPathLocal Condition=" '$(sc-MSBuildLibPathLocal)'=='' ">$(LocalAppData)\Microsoft\MSBuild\SlowCheetah\v2.5.10.2\</sc-MSBuildLibPathLocal>
To:
<sc-MSBuildLibPathLocal Condition=" '$(sc-MSBuildLibPathLocal)'=='' ">$(LocalAppData)\Microsoft\MSBuild\SlowCheetah\v2.5.10.3\</sc-MSBuildLibPathLocal>
Why it was pointed to v2.5.10.2 is a mystery, but I'm definitely using v2.5.10.3! Looks like the nuget package itself has the bug in it.
I resolved it like this:
Uninstall slowcheetah => Tools>Extensions and Updates
click OK when VS asks you to restart VS.
in "C:\Users\AppData\Local\Microsoft\MSBuild\SlowCheetah" remove the 'v1' folder (which windows automatically creates when restarting your VS) (here be dragons..)
reïnstall slowcheetah (see step 1) => a new folder v2.5.10.2 will be created.
Again, click OK when he asks to restart
Build your solution
Regards,
Peter
This problem went away for me after using the preview transformation feature in the context menu. Originally suggested here.
FYI this was on VS 2010 Premium.
Having multiple versions can lead to conflicts.
In my case I have installed both Microsoft.VisualStudio.SlowCheetah by Microsoft and SlowCheetah by Sayed Ibrahim Hashimi. After uninstalling the package from Microsoft everything went well.
I have deleted the old files in C:\Users\\AppData\Local\Microsoft\MSBuild\SlowCheetah\v1. I also needed to upgrade Visual Studio 2012 to update 4 to make it work.
I was able to fix this issue by doing the following:
Uninstalling the SlowCheetah extension from the TOOLS > Extensions and Updates... menu
Closing Visual Studio
Deleting all files in the "C:\Users\username\AppData\Local\Microsoft\VisualStudio\11.0\Extensions" folder
Opening Visual Studio
Reinstalling SlowCheetah from the TOOLS > Extensions and Updates... menu (which requires a Visual Studio restart)
This is using Visual Studio 2012 Premium with Update 4 and SlowCheetah version 2.5.10.
If you're getting this error on a TFS Build Server (in my case TFS Express 2013) then you will need to copy over the files from your local machine
C:\Users\SWEAVER\AppData\local\Microsoft\MSBuild\SlowCheetah
on your machine to whichever user your TFS build is running under
C:\users\TFSBuild\AppData\Local\Microsoft\MSBuild\SlowCheetah
Please note AppData is a hidden directory that you may not see, but just type the name and hit enter and it will come up.
I'm using VS2013 so I didn't copy v1 (I think v1 is for VS2012).
The original TFS error I got was :
C:\Builds\1\www.XXXXX.com\RRStore - XXXXX
Silverlight\Sources\RRStore.AdminConsole\Properties\SlowCheetah\SlowCheetah.Transforms.targets
(150): The "SlowCheetah.Xdt.TransformXml" task could not be loaded
from the assembly
C:\Users\TFSBuild\AppData\Local\Microsoft\MSBuild\SlowCheetah\v2.5.10.2\SlowCheetah.Xdt.dll.
Could not load file or assembly
'file:///C:\Users\TFSBuild\AppData\Local\Microsoft\MSBuild\SlowCheetah\v2.5.10.2\SlowCheetah.Xdt.dll'
or one of its dependencies. The system cannot find the file specified.
Confirm that the declaration is correct, that the assembly
and all its dependencies are available, and that the task contains a
public class that implements Microsoft.Build.Framework.ITask.
Fortunately this error told me exactly where to place the files.
I had the same problem in Visual Studio 2013. Just install SlowCheetah NuGet package:
https://www.nuget.org/packages/SlowCheetah
They've released a new version which brings the installation procedure up to date:
https://blogs.msdn.microsoft.com/visualstudio/2017/05/25/whats-new-and-improved-with-the-slowcheetah-extension/
Tired of having to install your NuGet packages manually to get
SlowCheetah to work? We’ve added automatic NuGet installation to help
streamline your process. All you need to install is the latest
extension and SlowCheetah will take care of the rest. When you use
SlowCheetah for the first time in a project, it will prompt you to
install or update NuGet packages. Agree and you’re ready to go!
Close Visual Studio
Install the VISX extension
Open your project.
This version detects if you already have it installed and offers to upgrade.
I would recommend checking in to source control and then doing a compare of your .csproj file to see what changes it made.

Resources