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

Versions after v3.3.37 doesn't work on Windows 7 #615

Closed
fehrm opened this issue Jun 12, 2021 · 6 comments · Fixed by #616
Closed

Versions after v3.3.37 doesn't work on Windows 7 #615

fehrm opened this issue Jun 12, 2021 · 6 comments · Fixed by #616
Assignees
Labels
Milestone

Comments

@fehrm
Copy link

fehrm commented Jun 12, 2021

With version after v3.3.37, NBGV fails when doing a simple dotnet build in new repo.

Error is as follows:

error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
error MSB4018: System.EntryPointNotFoundException: Unable to find an entry point named 'CreateFile' in DLL 'api-ms-win-core-file-l1-2-0.dll'.
error MSB4018: at PInvoke.Kernel32.CreateFile(Char* filename, ACCESS_MASK access, FileShare share, SECURITY_ATTRIBUTES* securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
error MSB4018: at PInvoke.Kernel32.CreateFile(String filename, ACCESS_MASK access, FileShare share, SECURITY_ATTRIBUTES* securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
error MSB4018: at PInvoke.Kernel32.CreateFile(String filename, ACCESS_MASK access, FileShare share, Nullable`1 securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
error MSB4018: at Nerdbank.GitVersioning.ManagedGit.FileHelpers.TryOpen(String path, FileStream& stream)
error MSB4018: at Nerdbank.GitVersioning.ManagedGit.GitRepository..ctor(String workingDirectory, String gitDirectory, String commonDirectory, String objectDirectory)
error MSB4018: at Nerdbank.GitVersioning.ManagedGit.GitRepository.Create(String workingDirectory)
error MSB4018: at Nerdbank.GitVersioning.Managed.ManagedGitContext..ctor(String workingDirectory, String dotGitPath, String committish)
error MSB4018: at Nerdbank.GitVersioning.GitContext.Create(String path, String committish, Boolean writable)
error MSB4018: at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner()

For full error, see last step.

Running command ver on my machine

Microsoft Windows [Version 6.1.7601]

Steps to reproduce

  1. dotnet --version

3.1.410

  1. dotnet new console
  2. git init
  3. git add -A && git commit -m "init"
  4. dotnet tool install -g nbgv
  5. nbgv install
  6. git add -A && git commit -m "nbgv"
  7. dotnet build

Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Determining projects to restore...
All projects are up-to-date for restore.
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: System.EntryPointNotFoundException: Unable to find an entry point named 'CreateFile' in DLL 'api-ms-win-core-file-l1-2-0.dll'.
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at PInvoke.Kernel32.CreateFile(Char* filename, ACCESS_MASK access, FileShare share, SECURITY_ATTRIBUTES* securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at PInvoke.Kernel32.CreateFile(String filename, ACCESS_MASK access, FileShare share, SECURITY_ATTRIBUTES* securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at PInvoke.Kernel32.CreateFile(String filename, ACCESS_MASK access, FileShare share, Nullable`1 securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.ManagedGit.FileHelpers.TryOpen(String path, FileStream& stream)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.ManagedGit.GitRepository..ctor(String workingDirectory, String gitDirectory, String commonDirectory, String objectDirectory)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.ManagedGit.GitRepository.Create(String workingDirectory)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.Managed.ManagedGitContext..ctor(String workingDirectory, String dotGitPath, String committish)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.GitContext.Create(String path, String committish, Boolean writable)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner()

Build FAILED.

C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: System.EntryPointNotFoundException: Unable to find an entry point named 'CreateFile' in DLL 'api-ms-win-core-file-l1-2-0.dll'.
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at PInvoke.Kernel32.CreateFile(Char* filename, ACCESS_MASK access, FileShare share, SECURITY_ATTRIBUTES* securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at PInvoke.Kernel32.CreateFile(String filename, ACCESS_MASK access, FileShare share, SECURITY_ATTRIBUTES* securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at PInvoke.Kernel32.CreateFile(String filename, ACCESS_MASK access, FileShare share, Nullable`1 securityAttributes, CreationDisposition creationDisposition, CreateFileFlags flagsAndAttributes, SafeObjectHandle templateFile)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.ManagedGit.FileHelpers.TryOpen(String path, FileStream& stream)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.ManagedGit.GitRepository..ctor(String workingDirectory, String gitDirectory, String commonDirectory, String objectDirectory)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.ManagedGit.GitRepository.Create(String workingDirectory)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.Managed.ManagedGitContext..ctor(String workingDirectory, String dotGitPath, String committish)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.GitContext.Create(String path, String committish, Boolean writable)
C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.205\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner()
0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.14

@AArnott AArnott self-assigned this Jun 12, 2021
@AArnott AArnott added this to the v3.4 milestone Jun 12, 2021
AArnott added a commit that referenced this issue Jun 12, 2021
@AArnott AArnott linked a pull request Jun 12, 2021 that will close this issue
@AArnott
Copy link
Collaborator

AArnott commented Jun 12, 2021

Would you be willing to test the fix, which you can download from the build artifact in #616's PR build?

@AArnott
Copy link
Collaborator

AArnott commented Jun 12, 2021

I guess that invitation was a bit premature. The PR build failed. I'll work on it.

@fehrm
Copy link
Author

fehrm commented Jun 13, 2021

First, thanks for answering so quickly.

I'll gladly test it when it is ready!

@AArnott
Copy link
Collaborator

AArnott commented Jun 13, 2021

@fehrm
Copy link
Author

fehrm commented Jun 13, 2021

Worked first try, added it as a local NuGet package for same Console project and made sure it was being used:

  1. dotnet build -v d

[...]
2>Target "GetBuildVersionCore" in project "C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.217-gbfab409102\build\Nerdbank.GitVersioning.Inner.targets" (target "GetBuildVersion_Properties" depends on it):
Using "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task from assembly "C:\Users\user\.nuget\packages\nerdbank.gitversioning\3.4.217-gbfab409102\build\MSBuildCore/Nerdbank.GitVersioning.Tasks.dll".
Task "Nerdbank.GitVersioning.Tasks.GetBuildVersion"
Done executing task "Nerdbank.GitVersioning.Tasks.GetBuildVersion".
[...]

Build succeeded.
0 Warning(s)
0 Error(s)

Amazing, thanks!

@AArnott
Copy link
Collaborator

AArnott commented Jun 13, 2021

Thanks for verifying!

@AArnott AArnott closed this as completed Jun 13, 2021
@AArnott AArnott added the bug label Jun 13, 2021
AArnott added a commit that referenced this issue Aug 28, 2021
* Switch from PInvoke nuget dependency to CsWin32

Fixes #615

* Update CsWin32 to fix `dotnet build`

* Remove dotnet/pinvoke from 3rd party licenses file

* include 5E and DA values in zlib header check

* ditch linq for exception

* Add new NuGet signing certificate

See https://devblogs.microsoft.com/nuget/the-nuget-org-repository-signing-certificate-will-be-updated-as-soon-as-march-15th-2021/ for more details

* Bump libgit2sharp to 0.27.0-preview-0102

* Run 32-bit tests

* GitPack: Don't use MemoryMappedFiles in 32-bit processes

* Make sure Streams are disposed of.

* Fix bugs with > 2 GB pack files

* Apply suggestions from code review

Co-authored-by: Andrew Arnott <andrewarnott@gmail.com>

* Apply `is null` pattern and analyzer

Co-authored-by: rhodosaur <hai@rsaur.me>
Co-authored-by: Frederik Carlier <frederik.carlier@quamotion.mobi>
Co-authored-by: Filip Navara <navara@emclient.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants