-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-2088: Publish PDBs and sources on symbolsource. #694
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
Conversation
47944a2
to
5fe0f04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Very excited to see this feature enabled.
dotnet new console
dotnet add package MongoDB.Driver --version 2.14.0-csharp2088-4-1 --source https://www.myget.org/F/mongodb/api/v3/index.json
I configured JetBrains Rider to use the following Symbol Server as documented by myget.org:
https://www.myget.org/F/mongodb/api/v2/symbolpackage/
I then created a simple MongoDB program and was able to successfully debug into db.GetCollection<BsonDocument>("coll")
! I confirmed that I had debugged into our actual sources by verifying that source comments were present along with our copyright. When working with decompiled sources, source comments aren't present (for obvious reasons) and rather than the copyright there is a "decompiled by" comment at the top of the file.
I had some initial fumbling around with configuration. Without explicitly adding the Symbol Server, you still get decompiled sources. So we will have to add some documentation on how to enable source debugging with our driver.
build.cake
Outdated
RunTarget(target); | ||
|
||
public class BuildData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BuildConfig
might be a better name for this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
string s when s.StartsWith("test") && s.EndsWith("netstandard20") => "netcoreapp2.1", | ||
string s when s.StartsWith("test") && s.EndsWith("netstandard21") => "netcoreapp3.1", | ||
_ => null | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the centralization of this logic! It removes a lot of code duplication from our Cake script. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
src/MongoDB.Bson/MongoDB.Bson.csproj
Outdated
@@ -27,6 +27,10 @@ | |||
<PackageTags>mongodb;mongo;nosql;bson</PackageTags> | |||
<PackageLanguage>en-US</PackageLanguage> | |||
<IncludeSymbols>true</IncludeSymbols> | |||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | |||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | |||
<!--obj--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it says that EmbedUntrackedSources
is responsible for obj
folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Based on this article and this issue it looks like at least it affects
AssemblyInfo.cs
which is placed inobj\Release\{Framework}\
. I didn't check further, but in this file we may apply global assembly attributes that could be missed? Anyhow it looks like this option is always recommended. - Also some article that recommends setting it.
src/MongoDB.Bson/MongoDB.Bson.csproj
Outdated
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<!--obj--> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be using this option? If a source file isn't in GitHub then there is a reason. And source files excluded from GitHub might contain secrets that we don't want shared. While I am not aware of any passwords or private keys embedded in our source, it seems like a risky option to enable. What are the consequences of setting this option to false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's required to have files in obj
folder available in debugging, I need to refresh my memory to recall what will happen if we remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in Slack and decided that safer to not embed untracked files by default. We can revisit this decision if users report debugging problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant to select "request changes" on my last review. Minor questions/suggestions only. Overall it works as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great overall.
Confirmed that it works, exited to see this great enhancement for our debugging experience!
string s when s.StartsWith("test") && s.EndsWith("netstandard20") => "netcoreapp2.1", | ||
string s when s.StartsWith("test") && s.EndsWith("netstandard21") => "netcoreapp3.1", | ||
_ => null | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
Console.WriteLine("Build continuousIntegration is enabled"); | ||
settings.MSBuildSettings = new DotNetCoreMSBuildSettings(); | ||
// needs to make nupkg package deterministic. Should be used only during package release | ||
settings.MSBuildSettings.SetContinuousIntegrationBuild(continuousIntegrationBuild: true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to always use SetContinuousIntegrationBuild
and skip having IsReleaseMode
)as we don't use cake for debug/dev env.)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we don't use cake for debug/dev env.)?
it sounds like it's possible, at least I wasn't able to reproduce any issues in our tests (including for tests that work with system paths). However given that it's recommended to set it only for non local development:
While deterministic builds are enabled by default in .NET SDK projects, there is an extra property, ContinuousIntegrationBuild, to set on the build server to normalize stored file paths. These should not be enabled during local dev or the debugger won’t be able to find the local source files.
I would probably prefer to leave this check (to fully follow the guide), however I can rely on you and @JamesKovacs here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only publish release mode assemblies. If you're in debug mode for the driver, you're debugging through your local sources. You don't need to reach out to a source server to download a nuget package containing PDB files because you've got the PDB files on your local file system already. We should leave this check in place IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hashed out in Slack. Our decision was to use @BorisDog's suggested comment:
configure deterministic build for better compatibility with debug symbols (used in Package/Build tasks)
And add @DmitryLukyanov's note to the comment about whether nupkg
or snupkg
is affected by the specific call to SetContinuousIntegrationBuild
.
build.cake
Outdated
@@ -65,7 +66,7 @@ Task("Restore") | |||
|
|||
Task("Build") | |||
.IsDependentOn("Restore") | |||
.Does(() => | |||
.Does<BuildConfig >((buildConfig) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra space: <BuildConfig >
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
build.cake
Outdated
@@ -798,8 +783,36 @@ Task("TestsPackaging") | |||
}) | |||
.DeferOnError(); | |||
|
|||
Setup<BuildConfig >( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Some notes:
After this PR, the nuget package manager should look like this:
NOTE: it looks like myget doesn't work correctly with the above package validation, all nuget packages that I checked (including external) were red. Probably it's only myget issue. Will check it after release :)
ContinuousIntegration
field that required to make package deterministic. Some article about it here.where
Url
means the git repository that will be used to download source file andCommit
a particular commit (make sure that it's pushed).5.1. While we use myget in testing, this source
https://www.myget.org/F/mongodb/api/v3/index.json
should be added to nuget package manager.5.2. Consume the test package in the consumer application
5.3. Make sure that VS has the same configuration:
5.4. Make sure that myget symbol server
https://www.myget.org/F/mongodb/api/v2/symbolpackage
is added to VS here:NOTE: I think when we will use nuget.org symbol server, it should be enough just to enable default nuget symbol server