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

[Bug] The process cannot access the file '...\obj\gitversion.json' because it is being used by another process. #2578

Closed
SeppPenner opened this issue Feb 2, 2021 · 2 comments · Fixed by #2581
Labels
Milestone

Comments

@SeppPenner
Copy link

Describe the bug
When you have a project specifiying multiple target frameworks, the parallel build using dotnet build seems to crash the generation of the gitversion.json file.

Expected Behavior

It should just build all target frameworks. My assumption is that this only occurs when you specify more than 1 target framework as I have other projects just targeting net5.0 without any problems.

Actual Behavior

When you build, the gitversion.json locked exception occurs in the command line:

Serilog.Sinks.Telegram -> C:\Users\Nutzer\Documents\Temp\Github\CSharpUndVB\Serilog.Sinks.Telegram\src\Serilog.Sinks.Telegram\bin\Debug\net462\Serilog.Sinks.Telegram.dll
    ERROR [02/02/21 9:12:20:47] An unexpected error occurred:
  System.IO.IOException: The process cannot access the file 'C:\Users\Nutzer\Documents\Temp\Github\CSharpUndVB\Serilog.Sinks.Telegram\src\Serilog.Sinks.Telegram\obj\gitversion.json' because it is being used by another process.
     at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
     at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
     at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize)
     at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
     at System.IO.File.WriteAllText(String path, String contents, Encoding encoding)
     at GitVersion.FileSystem.WriteAllText(String file, String fileContents, Encoding encoding) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Core\FileSystem.cs:line 47
     at GitVersion.FileSystem.WriteAllText(String file, String fileContents) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Core\FileSystem.cs:line 42
     at GitVersion.VersionConverters.OutputGenerator.OutputGenerator.Execute(VersionVariables variables, OutputContext context) in D:\a\GitVersion\GitVersion\src\GitVersionCore\VersionConverters\OutputGenerator\OutputGenerator.cs:line 39
     at GitVersion.GitVersionOutputTool.OutputVariables(VersionVariables variables, Boolean updateBuildNumber) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Core\GitVersionOutputTool.cs:line 42
     at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersionExe\GitVersionExecutor.cs:line 66
    INFO [02/02/21 9:12:20:47] Attempting to show the current git graph (please include in issue):
    INFO [02/02/21 9:12:20:47] Showing max of 100 commits
    INFO [02/02/21 9:12:20:52] * 39b6b89 3 days ago  (HEAD -> master, origin/master, origin/HEAD)
  * f81b88f 5 days ago  (tag: 1.0.8)
  *   5fc8ab7 5 days ago
  |\
  | * 877c361 7 days ago
  | * e4e1ae1 8 days ago
  |/
  * dd27c4a 3 weeks ago
  * 124f098 4 weeks ago
  * 7d2aea9 4 weeks ago  (tag: 1.0.7)
  * 5ab0027 4 weeks ago  (tag: 1.0.6)
  * ff56bb9 4 weeks ago
  * b744730 4 weeks ago  (tag: 1.0.5)
  * 8e646a3 4 weeks ago
  *   3349b06 4 weeks ago
  |\
  | * cfa9759 9 months ago  (jessicah-origin/master)
  * | 60c4560 4 weeks ago
  * | 9bf0d87 4 weeks ago
  * | 6e9ddb1 4 weeks ago
  * | 2653445 4 weeks ago
  * | 62d183f 4 weeks ago
  * | 22d5d61 4 weeks ago
  * | 0c14d3e 4 months ago  (tag: 1.0.4)
  * | 9572efc 4 months ago
  * | c8f57e3 4 months ago
  * | 585f8e6 4 months ago
  * | 30db99e 8 months ago  (tag: 1.0.3)
  * | f58a4d9 9 months ago
  * | 718aa3d 9 months ago
  |/
  * 5ff558d 9 months ago
  * 3eb7b99 9 months ago
  * c2c819c 9 months ago  (tag: 1.0.2)
  * c29320e 1 year, 3 months ago
  * f11ed6f 1 year, 3 months ago
  * 16b6cf3 1 year, 3 months ago  (tag: 1.0.1)
  * 28deab3 1 year, 3 months ago
  * b6b710c 1 year, 3 months ago
  * a0a042f 1 year, 7 months ago
  * e80f820 1 year, 7 months ago
  * b3a4ea5 1 year, 7 months ago

Possible Fix

No idea.

Steps to Reproduce

  1. Use e.g. https://github.com/SeppPenner/Serilog.Sinks.Telegram with<TargetFrameworks>net46;net462;net47;net472;net48;netstandard2.0;netstandard2.1;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
  2. Run dotnet build from the command line in the Serilog.Sinks.Telegram folder on project level.

Context

Daily work, updating my nuget packages.

Your Environment

dotnet --info:

.NET SDK (gemäß "global.json"):
 Version:   5.0.102
 Commit:    71365b4d42

Laufzeitumgebung:
 OS Name:     Windows
 OS Version:  10.0.19041
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.102\

Host (useful for support):
  Version: 5.0.2
  Commit:  cb5f173b96

.NET SDKs installed:
  2.1.806 [C:\Program Files\dotnet\sdk]
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.202 [C:\Program Files\dotnet\sdk]
  3.1.300 [C:\Program Files\dotnet\sdk]
  3.1.402 [C:\Program Files\dotnet\sdk]
  5.0.100 [C:\Program Files\dotnet\sdk]
  5.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
@github-actions
Copy link

github-actions bot commented Feb 7, 2021

🎉 This issue has been resolved in version 5.6.5 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

@SeppPenner
Copy link
Author

@arturcic and @MarkusHorstmann Thanks for the update, I can confirm that the issue is gone now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants