New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make engine easier to Debug #551
Comments
I ran into the same issue as in 1. when I did some debugging at work. But I think that from 3.10 we will actually get PDBs in the packages (at least in the zip-files) - at least I did when executing the target with "package". I guess this is a sideeffect of #388, but have not examined it in any detail. Regarding 2. I think we could do it differently without harming people, and I don't know if there is a standard way to do this (meaning having debug builds in nuget). Regarding 3. I won't mind separate build targets, but I do not know much about the history in this area. |
I'm using the current master, which includes #388 and I'm not seeing pdbs in the nuget packages. |
You are right Charlie. I was sure that I checked that the output contained PDBs because I was about to create an issue for this a couple of weeks ago, but I did a final check and then I thought that it was already solved on master. But I must have made an mistake when I did the check. |
Let me throw in another item that I think would make life easier:
|
So far, @mikkelbu has responded. I'd rather see some others comments before I put any effort into a PR. At the moment, based on Mikkel's feedback, I would be inclined to put in a PR that covered 1, 2 and 4. |
I’d like to hear @jnm2’s thoughts on pdbs, after all the work he did in the framework here recently, I remember we discussed several options. We absolutely should have something! 4 is fine by me. 2, I have no strong opinions on - could you just clarify the problems this is currrently causing, for interests sake? 3 also, can you clarify what you’re suggestion? Doesn’t the cake script already cater for this? |
@ChrisMaddock Enlarging on some of the points you mentioned.
It would be convenient to me to be able to just build the engine, just test the engine and just package the engine in a particular way. Of course, the overall build would still have to do everything but the individual commands would be broken down more than they now are. I could probably explain this better by just doing a PR. 😃 I would also find it convenient to be able to build for a particular target only. That may take some playing around to get it to work.
|
Thanks Charlie, all sound good to me. I'd mis-remembered the Cake script, I thought we already had separate engine/console targets. On pdb's - I think for the framework we include both pdbs and some SourceLink as well. Would be nice to get the engine to the same end point - but adding the pdb's would be a good incremantal step towards that! |
The Cake targets are separate for test, but the build is unified and the packaging is broken down by package type rather than engine versus console. I think I'm comfortable enough to do a PR at this point, which will probably drive out further comments. |
I'm going to do each item as a PR, which will make them pretty small. That's how I'm currently working in the GUI and I really like it. WRT item 3, I'm not sure it possible without major changes to how the build is done, which I feel is out of scope for my role. I'll look more closely before deciding whether to drop it. |
I think including the PDBs is a good idea. I'm not sure how useful they are if they aren't SourceLinked though. For 2, I think it is fine to change although should we ever be publishing debug builds? For that, I usually publish the NuGet packages to a local folder that I have set up in Visual Studio as a package source. For 3, I don't think there is any reason not to have multiple targets. I'm actually surprised we don't 😄 |
WRT 2, I think Rob has the right idea. If people want to test using a debug build, it shouldn't require a change in version, just in the feed from which they download. Of course, without package source it's only useful for those who have a copy of the source locally, but since that includes me, I'm happy. |
The current planning (summarized at https://github.com/NuGet/Home/wiki/NuGet-Package-Debugging-&-Symbols-Improvements) is to introduce a new Wherever the PDBs end up going, there are generally three options:
If you like, I can make sample .nupkgs to prepare a table of final sizes like I did for the other two: nunit/nunit#2421 (comment) |
I do really want to get source-stepping enabled, by the way. Last week it would have saved me a number of minutes at least when I was investigating a reported issue with the adapter. |
I'd like to get this issue closed one way or another! 😃 I handled items 2 and 4 in separate PRs, which leaves items 1 (PDBs) and 3 (separate builds of engine and console). @jnm2 did a nice summary, with recommendations, about pdbs. The framework project initially used GitLink but switched to SourceLink early this year. It seems to me that this may be an area where the projects should not operate completely independently. Should we be using SourceLink for all projects? All key projects? @nunit/engine-team What do you think? Several of us were surprised that the engine and console builds were not separate targets. That's because there's only a single solution and that's what we build. Question: Is it worth changing that? If so, we can take two approaches: either build a list of projects for the engine and another for the console or create separate solutions for the engine and console. Personally, I think it's too much trouble unless we intend to entirely separate the release of the engine from that of the console runner. Thoughts? |
I think we should go for SourceLink and make it similar to how we do it for the framework project.
It also sounds like trouble for me - but I don't feel that strongly about this issue, as I cannot remember having noticed or been affected by this. |
My thoughts:
|
So, based on that feedback, which happens to match my own opinion, I'll drop item 3 (separate builds) and take a look at using SourceLink. That way we can finish up the issue. @ChrisMaddock I'm not generally a fan of standardizing across projects but it may be convenient here, since NUnit users may need to debug into both the engine and the framework. I'm going to do the same for the GUI runner. Do you want to switch to SourceLink in the current master or for the 4.0 release? |
I know relatively little about best practices here, but my understanding from Joseph’s explanation above is that snupkgs are the “new” way, and including in the nupkg is the old way. If this is going to be a new feature for the engine, do we want to support old dev environments? I don’t feel strongly either way - but if we’re going to do one or the other, the current best practice feels preferable. Charlie - do you know any more than I do about the pros/cons here? Like I say, packing symbols isn’t something I’ve ever done before. |
I don't know any more than you... all I did was read the docs. Microsoft guidance says to not include the pdbs in the nupkg, which seems to me to make you dependent on a connection. Also, AFAIK I know that @jnm2 has continued to work in this area with the Cake project and others. His comments above are three years old now, so things have likely changed. @jnm2 can you give some advice here? One possibility is to commit what I have so far... pdbs in the distribution. That makes it easy for anyone who already has the source... contributors, extenders, ourselves... to debug a package. It doesn't help the general user community, but maybe that's another step. |
I use snupkg with MyGet also. I would recommend using the snupkg format because the nuget.org symbol server is enabled in VS by default and therefore consumers have the least burden possible (assuming they are referencing a package on nuget.org). If they are referencing a package on MyGet, they'll need to paste in the url to the symbol server for your MyGet feed name. I have example directions for this at https://github.com/Techsola/InstantReplay#debugging-into-techsolainstantreplay-source. The problem with placing .pdb files in the nupkg is that the .NET SDK no longer copies PDBs to build output, and so they are not automatically loaded when the consumer turns off Just My Code. To use them, the consumer must have foreseen this eventuality by putting an obscure line in her csproj to cause .pdb files to be copied from dependency packages to build output before running her app, or she must browse into None of the above means you can't put .pdb files other places in addition to snupkg→symbol server, however you find useful for yourself and your users. There is one other option which is to embed the PDB into your assemblies themselves with
Lastly, the decision between embedding all source or using SourceLink to download on demand from raw.githubusercontent.com is a setting entirely independent of all of the above. |
@jnm2 I'm afraid I'm left even more confused! What about the approach that @rprouse took with the framework - using two different @ChrisMaddock If we can't make an ultimate decision right now. I propose to merge what I have here so far. That will at least give some of us what we need. (I wrote the issue in the first place in order to help myself!) |
@CharliePoole It can be confusing. There are two things to think about separately: symbols (PDBs), which allow debugging, and source, which allows seeing source code for what you are debugging. SourceLink is an optional addition to PDBs. It's a small JSON file inside the PDB that says "here's where to download source code from the internet." Even if you have the PDB loaded in Visual Studio, you need an internet connection each time you step into a new source file if you want to see the source code. An alternative to SourceLink is embedding source files within the PDB. If you use embedded source, the .cs files are compressed and included inside the PDB content. Once the PDB file is loaded in Visual Studio, you don't need an internet connection each time you step into a new source file if you want to see the source code. Both of these things are independent of how you decide to distribute the PDB content itself, which is what my previous comment talks about. My previous comment talks about "I have an assembly; now how do I get the PDB for it?" SourceLink doesn't come in to that question. SourceLink is one answer to a different question: "I have an assembly and I also have a PDB; now how do I get the source code for it?" Embedded source is another answer. |
The reason Rob used two .nuspec files is because he was creating a .snupkg file as well as a .nupkg file. It's rare and difficult to manage your own .nuspec these days compared to letting the .NET SDK generate the .nuspec based on your .csproj file, unless you're unlucky enough to be doing something the SDK doesn't support. If the NUnit framework was letting the SDK generate the nuspec, Rob would have put What having a .snupkg file accomplishes is to distribute your PDB content to symbols.nuget.org or MyGet symbol servers. When a .snupkg file is next to a .nupkg file, the same None of this has to do with SourceLink though. Snupkg is a PDB distribution mechanism. SourceLink is not. SourceLink is a PDB addition that enables debuggers like VS to download source files on demand while debugging. You can use SourceLink without snupkg and snupkg without SourceLink, or both or neither. They aren't aware of each other. |
@jnm2 Yes, I get the part about "two things." My confusion is that you need both, but when I pack the nuget file using If I understand correctly, restoring the nuget package gets the pdbs for the user, provided the snupkg is also pressent. What I don't get is why nunit.framework is forcing the nupkg to also contain pdbs, in spite of creating an snupkg. We talked about making the console consistent with the framework, but... that seems unnecessary... Am I missing something? Also... what about other, non-nuget packages: chocolatey, the msi, the zip package? How would you recommend handling them? You've experimented with this stuff, I know... if I want to run some experiments, do I need a clean VM or will a clean directory suffice? Charlie |
Ah... we crossed... i see the answer now about the framework approach. I could see switching to use of the project properties. What do you think @ChrisMaddock . Of course we would still need to handle the non-nuget packages we distribute in some way but at least the nuget part would be simpler. |
This might be a better summary than my first ones. "How will people load my PDB?" Options:
"How will people see my source code after they have loaded my PDB?" Options:
|
Oops, my messages crossed too. I'm just now seeing your two replies. 👍
Not quite. With snupkg, the PDBs are not obtained until the debugger contacts a symbol server in an attempt to load symbols for your assembly while debugging. Restoring the package gets you only what is in the nupkg. The snupkg doesn't really come back; the PDBs inside it get indexed in a standard symbol server.
Having PDBs in the main package is not normal if you are using a snupkg. This might come down to the fact that @rprouse is creating the nuspec by hand and starting from a nuspec that did include PDBs in the main package.
I would put PDBs in the .zip download for sure or else have a separate .zip download just for them, just so they are easy to find if someone wants to grab them manually. I wouldn't distribute PDBs via chocolatey or MSI because 1) people who debug them will be able to use the symbol server and 2) I think it's a tiny minority of people who will want to debug things distributed via chocolatey/MSI, and adding the PDB to the download and install size isn't worth it to me subjectively.
A clean directory will probably work, but you might need to delete a PDB cache if you want to test resolving the same PDB more than once. Once resolved, VS will cache a PDB rather that trying symbol servers again. Let me know if I missed answering something else. |
Enough food for thought at least for now... 😃 Thanks! |
@ChrisMaddock I'm pretty well convinced by @jnm2 's comments.
Of course, that means I'll have to undo some work for (1), but it's cool... a learning experience. For the nuget packages, I'm inclined to stick with what we are already doing and look into switching to project properties as a future step. Personally, I'd rather try it with a simpler project first. What do you think? |
I was debugging a project referencing the latest release of the framework and stepping into the framework with the new snupkg was a great experience. We'll need to test how it works with the engine, but I highly recommend it. |
It took me a lot of trial and error because most of the docs are based on creating the packages using the project file. With the nuspec file, when you compile it, the PDBs end up in the snupkg and the DLLs in the nupkg. I tried two nuspec files, but it didn't work. Everything had to be in one and the compiler puts the correct files in the correct package. |
Ah! Now I see why I was confused. I was looking at a clone of the framework, which was out of date and apparently had one of your experiments in it. That's why I kept asking about "two nuspecs." In fact, I've done similar experiments as you must have done and learned how nuget creates two packages from one file. That's barely documented at all. |
@ChrisMaddock I think we have enough info to decide. I have this blocked because I don't feel it's my decision to make. Per @jnm2 and @robs input and my own comment of four days ago, I think we should...
However, I don't have strong feelings about it and I'll do as much or as little of it as you like. |
This sounds good to me 👍 Did you have any thoughts on SourceLink vs embedding sources? SourceLink would be my preference from the info Joseph has provided I think, but I don't feel strongly. Re: switching from nuspecs to project files, I agree we should do that separately. It would be good to do at some point though - another one for the "making maintenance easier" list! |
OK... I'll move ahead then. I'll leave conversion to the project file for somebody else to pick up at a future point. I may have to leave this until the end of the week as I'll be away. |
PR is ready to review. This is the last piece needed to complete the issue. |
I'm phrasing this as a set of questions. Depending on the answers, it might become a task.
When using the engine as a component of another runner via nuget, debugging is rather tricky.
Is there a reason that the pdb files are not distributed with the nuget packages? That's done with the adapter, for example.
If I build for debug, the version suffix changes in the assemblyinfo file. I'm wondering if use of "-dbg" at the end of the suffix is something folks are attached to or which seems like it would break anyone if we did it differently. I see a couple of alternatives
2.1 Add -dbg or (Debug) to the name component name, making it a different package
2.2 Don't change the name at all but just create a separate feed for debug builds.
How do you feel about having separate build targets for the engine and console?
These questions could apply to the framework as well, but it's the engine that I'm trying to debug under the GUI right now.
The text was updated successfully, but these errors were encountered: