Skip to content

Conversation

DmitryLukyanov
Copy link
Contributor

Some notes:

  1. Currently I temporally switched back to myget for tests reasons, probably we will know that it works with nuget only during next release.
  2. In the scope of this ticket I also fixed nuget package warnings from here and here. Steps that I took more or less taken from here.
    After this PR, the nuget package manager should look like this:
    image

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 :)

  1. I needed to update cake to 1.3.0, to be able to configure ContinuousIntegration field that required to make package deterministic. Some article about it here.
  2. What should be checked after package creating:
    image
    where Url means the git repository that will be used to download source file and Commit a particular commit (make sure that it's pushed).
  3. How it should be configured:
    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:
    image
    5.4. Make sure that myget symbol server https://www.myget.org/F/mongodb/api/v2/symbolpackage is added to VS here:
    image
    NOTE: I think when we will use nuget.org symbol server, it should be enough just to enable default nuget symbol server

@JamesKovacs JamesKovacs requested a review from BorisDog November 25, 2021 18:20
Copy link
Contributor

@JamesKovacs JamesKovacs left a 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
Copy link
Contributor

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.

Copy link
Contributor Author

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
};
Copy link
Contributor

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. 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@@ -27,6 +27,10 @@
<PackageTags>mongodb;mongo;nosql;bson</PackageTags>
<PackageLanguage>en-US</PackageLanguage>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!--obj-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line?

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are few reasons:

  1. Without this option, the package description triggers the warning:
    image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Based on this article and this issue it looks like at least it affects AssemblyInfo.cs which is placed in obj\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.
  2. Also some article that recommends setting it.

<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!--obj-->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

@JamesKovacs JamesKovacs self-requested a review November 25, 2021 22:24
Copy link
Contributor

@JamesKovacs JamesKovacs left a 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.

Copy link
Contributor

@JamesKovacs JamesKovacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@BorisDog BorisDog left a 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
};
Copy link
Contributor

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);
Copy link
Contributor

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.)?

Copy link
Contributor Author

@DmitryLukyanov DmitryLukyanov Dec 12, 2021

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.

Copy link
Contributor

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.

Copy link
Contributor

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) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra space: <BuildConfig >

Copy link
Contributor Author

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 >(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@DmitryLukyanov DmitryLukyanov merged commit b5e9da2 into mongodb:master Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants