Skip to content
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

nbgv for dotnetcore3.0 #326

Merged
merged 8 commits into from
May 9, 2019
Merged

nbgv for dotnetcore3.0 #326

merged 8 commits into from
May 9, 2019

Conversation

ctaggart
Copy link
Contributor

@ctaggart ctaggart commented Apr 23, 2019

Replaces #324 to address feedback. Closes #277

The publish step was what solves this error:

PS C:\Users\taggac\github\Nerdbank.GitVersioning> dotnet src\nerdbank-gitversioning.npm\out\nbgv.cli\tools\netcoreapp2.1\any\nbgv.dll get-version --format json
Error:
  An assembly specified in the application dependencies manifest (nbgv.deps.json) was not found:
    package: 'System.Security.Cryptography.ProtectedData', version: '4.3.0'
    path: 'runtimes/win/lib/netstandard1.3/System.Security.Cryptography.ProtectedData.dll'

By publishing, it works:

PS C:\Users\taggac\github\Nerdbank.GitVersioning> dotnet src\nerdbank-gitversioning.npm\out\nbgv.cli\tools\netcoreapp2.1\publish\nbgv.dll get-version --format json
{
  "CloudBuildNumber": "0.0.347+11b51ea17f",
  "CloudBuildNumberEnabled": false,
  "BuildMetadataWithCommitId": [
    "11b51ea17f"
  ],
  "VersionFileFound": false,
  "AssemblyVersion": "0.0.0.0",
  "AssemblyFileVersion": "0.0.347.46353",

I've looked at the diff, but I can't tell you what the root cause is. I just know that dotnet publish solves it.

Here is a diff:

cameron@USENTAGGACL1C:/mnt/c/Users/taggac/github/Nerdbank.GitVersioning/src/nerdbank-gitversioning.npm/out/nbgv.cli/tools/netcoreapp2.1$ diff -bur any publish
Only in any: DotnetToolSettings.xml
diff -bur any/nbgv.deps.json publish/nbgv.deps.json
--- any/nbgv.deps.json  2019-04-23 15:54:06.742695500 -0500
+++ publish/nbgv.deps.json      2019-04-23 15:54:16.827813400 -0500
@@ -6,7 +6,7 @@
   "compilationOptions": {},
   "targets": {
     ".NETCoreApp,Version=v2.1": {
-      "nbgv/2.3.147-g11b51ea17f": {
+      "nbgv/1.0.0": {
         "dependencies": {
           "Microsoft.Build": "15.9.20",
           "Nerdbank.GitVersioning.Core": "1.0.0",
@@ -726,7 +726,7 @@
     }
   },
   "libraries": {
-    "nbgv/2.3.147-g11b51ea17f": {
+    "nbgv/1.0.0": {
       "type": "project",
       "serviceable": false,
       "sha512": ""
Only in any/runtimes/alpine-x64: libgit2-a904fc6.so
Only in publish/runtimes/alpine-x64: native
Only in any/runtimes/debian.9-x64: libgit2-a904fc6.so
Only in publish/runtimes/debian.9-x64: native
Only in any/runtimes/fedora-x64: libgit2-a904fc6.so
Only in publish/runtimes/fedora-x64: native
Only in any/runtimes/linux-x64: libgit2-a904fc6.so
Only in publish/runtimes/linux-x64: native
Only in any/runtimes/osx: libgit2-a904fc6.dylib
Only in publish/runtimes/osx: native
Only in any/runtimes/rhel-x64: libgit2-a904fc6.so
Only in publish/runtimes/rhel-x64: native
Only in any/runtimes/ubuntu.18.04-x64: libgit2-a904fc6.so
Only in publish/runtimes/ubuntu.18.04-x64: native
Only in publish/runtimes/unix/lib: netstandard1.3
Only in any/runtimes/unix/lib: System.Security.Cryptography.ProtectedData.dll
Only in any/runtimes/unix/lib: System.Text.Encoding.CodePages.dll
Only in publish/runtimes/win/lib: netstandard1.3
Only in any/runtimes/win/lib: System.Security.Cryptography.ProtectedData.dll
Only in any/runtimes/win/lib: System.Text.Encoding.CodePages.dll
Only in any/runtimes/win-x64: git2-a904fc6.dll
Only in any/runtimes/win-x64: git2-a904fc6.pdb
Only in publish/runtimes/win-x64: native
Only in any/runtimes/win-x86: git2-a904fc6.dll
Only in any/runtimes/win-x86: git2-a904fc6.pdb
Only in publish/runtimes/win-x86: native

@ctaggart
Copy link
Contributor Author

I see the issue. The any folder is missing the native folder, which is expected.

C:\Users\taggac\github\Nerdbank.GitVersioning\src\nerdbank-gitversioning.npm\out\nbgv.cli\tools\netcoreapp2.1\any\runtimes\win-x64
C:\Users\taggac\github\Nerdbank.GitVersioning\src\nerdbank-gitversioning.npm\out\nbgv.cli\tools\netcoreapp2.1\publish\runtimes\win-x64\native

@ctaggart
Copy link
Contributor Author

native folder is created with dotnet 2.1.500, but not 2.2.105 or 2.2.203. Do you know what msbuild code copies these files?

@ctaggart
Copy link
Contributor Author

@tmat in dotnet/sourcelink#267 (comment) made it sound like there is a way to allows dotnet tools to roll forward.

Hunting for the correct setting in https://github.com/search?q=org%3Adotnet+roll+forward&type=Issues is probably a good start.

@ctaggart
Copy link
Contributor Author

Looks like we don't need a separate build. The current version works by setting environment variable DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX to 2

dotnet/arcade#1907
https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/roll-forward-on-no-candidate-fx.md

PS C:\Users\taggac\github\Nerdbank.GitVersioning> docker run --name nbgv -it --rm -v ${PWD}:/src -w /src -e DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2 mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview4
root@a7cd29cd1589:/src# dotnet tool install -g nbgv
Tools directory '/root/.dotnet/tools' is not currently on the PATH environment variable.
If you are using bash, you can add it to your profile by running the following command:

cat << \EOF >> ~/.bash_profile
# Add .NET Core SDK tools
export PATH="$PATH:/root/.dotnet/tools"
EOF

You can add it to the current session by running the following command:

export PATH="$PATH:/root/.dotnet/tools"

You can invoke the tool using the following command: nbgv
Tool 'nbgv' (version '2.3.138') was successfully installed.
root@a7cd29cd1589:/src# $HOME/.dotnet/tools/nbgv get-version
Version:                      0.0.349.57704
AssemblyVersion:              0.0.0.0
AssemblyInformationalVersion: 0.0.349+68e1675534
NuGet package Version:        0.0.349-68e1675534
NPM package Version:          0.0.349-68e1675534

Now, we just need to figure out how to update rollForwardOnNoCandidateFx property to distribute with build.

@@ -0,0 +1,3 @@
{
"rollForwardOnNoCandidateFx": 2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does the trick!

@ctaggart
Copy link
Contributor Author

This adds the rollForwardOnNoCandidateFx to:
C:\Users\taggac\github\Nerdbank.GitVersioning\bin\nbgv\Release\netcoreapp2.1\nbgv.runtimeconfig.json

{
  "runtimeOptions": {
    "tfm": "netcoreapp2.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.1.0"
    },
    "rollForwardOnNoCandidateFx": 2
  }
}

@@ -28,7 +28,7 @@
</PropertyGroup>
<ItemGroup>
<NpmPackageLayout Include="@(_PackageFiles)">
<TargetPath Condition=" '%(_PackageFiles.PackagePath)' != '' ">$(NpmPackageLayoutDir)$([System.IO.Path]::GetDirectoryName('%(_PackageFiles.PackagePath)'))\%(FileName)%(Extension)</TargetPath>
<TargetPath Condition=" '%(_PackageFiles.PackagePath)' != '' ">$(NpmPackageLayoutDir)%(_PackageFiles.PackagePath)\%(FileName)%(Extension)</TargetPath>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the line that was causing the native folder to be missing in the newer dotnet SDKs.

@ctaggart
Copy link
Contributor Author

This is ready for a squash merge. :-)

@ctaggart
Copy link
Contributor Author

ctaggart commented May 8, 2019

@AArnott, any chance of merging this soon? I saw there were updates to the roll-forward policy for .NET Core 3.0 Preview 5, but not sure that affects this.

@AArnott
Copy link
Collaborator

AArnott commented May 9, 2019

Sorry for the delay. I'm catching up on a big backlog of github notifications and this is the second-to-last one. Reviewing it now.

@AArnott AArnott merged commit a4c581a into dotnet:master May 9, 2019
@AArnott
Copy link
Collaborator

AArnott commented May 9, 2019

@ctaggart Can you take the latest build from CI and confirm that it does what you need, prior to my releasing to nuget?

@ctaggart ctaggart deleted the netcoreapp3.0 branch May 9, 2019 11:13
@ctaggart
Copy link
Contributor Author

ctaggart commented May 9, 2019

@AArnott I downloaded and tested the build. It is working. This shows it working with the 3.0 beta & alpine 3.9. 🎉

PS C:\Users\taggac\Downloads\deployables> docker run --name nbgv -it --rm -v ${PWD}:/src -w /src mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview5-alpine3.9
/src # dotnet tool install -g nbgv --add-source . --version 2.3.151
Tools directory '/root/.dotnet/tools' is not currently on the PATH environment variable.
If you are using bash, you can add it to your profile by running the following command:

cat << \EOF >> ~/.bash_profile
# Add .NET Core SDK tools
export PATH="$PATH:/root/.dotnet/tools"
EOF

You can add it to the current session by running the following command:

export PATH="$PATH:/root/.dotnet/tools"

You can invoke the tool using the following command: nbgv
Tool 'nbgv' (version '2.3.151') was successfully installed.
/src # $HOME/.dotnet/tools/nbgv get-version
Version:                      0.0.1.45168
AssemblyVersion:              0.0.0.0
AssemblyInformationalVersion: 0.0.1+70b0a091c6
NuGet package Version:        0.0.1-70b0a091c6
NPM package Version:          0.0.1-70b0a091c6
/src #

@AArnott
Copy link
Collaborator

AArnott commented May 9, 2019

Awesome. I've pushed 2.3.151 to nuget.org

AArnott added a commit that referenced this pull request Dec 27, 2024
Move variable definition script
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.

Add netcoreapp3.0 target for nbgv
2 participants