chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.36k stars 903 forks source link

Allow choco pack to run in parallel #653

Closed cwchapma closed 7 years ago

cwchapma commented 8 years ago

What You Are Seeing?

The process cannot access the file 'C:\ProgramData\chocolatey\config\chocolatey.config.update' because it is being used by another process.

What is Expected?

Parallel builds should just work ;)

How Did You Get This To Happen? (Steps to Reproduce)

I have a Visual Studio 2013 solution that builds many packages. By default, Visual Studio builds projects in parallel. I often get the above error with Chocolatey v0.9.9.11

Output Log

Visual Studio output:

1>------ Build started: Project: kxs-svn-x64, Configuration: Release Any CPU ------
2>------ Build started: Project: kxs-vs2013premium, Configuration: Release Any CPU ------
3>------ Build started: Project: kxs-tortoisesvn-x64, Configuration: Release Any CPU ------
4>------ Build started: Project: kxs-git, Configuration: Release Any CPU ------
5>------ Build started: Project: kxs-tortoisegit-x64, Configuration: Release Any CPU ------
6>------ Build started: Project: kxs-jdk7-x64, Configuration: Release Any CPU ------
7>------ Build started: Project: kxs-jdk7-i586, Configuration: Release Any CPU ------
8>------ Build started: Project: kxs-ultraedit-x64, Configuration: Release Any CPU ------
9>------ Build started: Project: kxs-ultracompare, Configuration: Release Any CPU ------
2>  Error serializing type chocolatey.infrastructure.app.configuration.ConfigFileSettings:
2>   The process cannot access the file 'C:\ProgramData\chocolatey\config\chocolatey.config.update' because it is being used by another process.
2>  Error updating 'C:\ProgramData\chocolatey\config\chocolatey.config'. Please ensure you have permissions to do so:
2>   The process cannot access the file 'C:\ProgramData\chocolatey\config\chocolatey.config.update' because it is being used by another process.
2>  Attempting to build package from 'kxs-vs2013premium.nuspec'.
2>  Successfully created package 'kxs-vs2013premium.12.0.40629.20150920.nupkg'
2>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
2>  E:\devops\development\Chocolatey\packages\kxs-visualstudio2013premium\src\kxs-vs2013premium.12.0.40629.20150920.nupkg
2>          1 file(s) moved.
5>  Attempting to build package from 'kxs-tortoisegit-x64.nuspec'.
5>  Successfully created package 'kxs-tortoisegit-x64.1.8.5.0.nupkg'
5>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
5>  E:\devops\development\Chocolatey\packages\kxs-tortoisegit64\src\kxs-tortoisegit-x64.1.8.5.0.nupkg
5>          1 file(s) moved.
4>  Error serializing type chocolatey.infrastructure.app.configuration.ConfigFileSettings:
4>   The process cannot access the file 'C:\ProgramData\chocolatey\config\chocolatey.config.update' because it is being used by another process.
4>  Error updating 'C:\ProgramData\chocolatey\config\chocolatey.config'. Please ensure you have permissions to do so:
4>   The process cannot access the file 'C:\ProgramData\chocolatey\config\chocolatey.config.update' because it is being used by another process.
4>  Attempting to build package from 'kxs-git.nuspec'.
4>  Successfully created package 'kxs-git.1.9.5.nupkg'
4>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
4>  E:\devops\development\Chocolatey\packages\kxs-git\src\kxs-git.1.9.5.nupkg
4>          1 file(s) moved.
1>  Attempting to build package from 'kxs-svn-x64.nuspec'.
1>  Successfully created package 'kxs-svn-x64.1.7.7.nupkg'
1>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
1>  E:\devops\development\Chocolatey\packages\kxs-svn64\src\kxs-svn-x64.1.7.7.nupkg
1>          1 file(s) moved.
6>  Attempting to build package from 'kxs-jdk7-x64.nuspec'.
6>  Successfully created package 'kxs-jdk7-x64.7.0.79.nupkg'
6>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
6>  E:\devops\development\Chocolatey\packages\kxs-jdk7-64\src\kxs-jdk7-x64.7.0.79.nupkg
6>          1 file(s) moved.
7>  Attempting to build package from 'kxs-jdk7-i586.nuspec'.
7>  Successfully created package 'kxs-jdk7-i586.7.0.79.nupkg'
7>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
7>  E:\devops\development\Chocolatey\packages\kxs-jdk7-i586\src\kxs-jdk7-i586.7.0.79.nupkg
7>          1 file(s) moved.
8>  Attempting to build package from 'kxs-ultraedit-x64.nuspec'.
8>  Successfully created package 'kxs-ultraedit-x64.22.20.nupkg'
8>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
8>  E:\devops\development\Chocolatey\packages\kxs-ultraedit-x64\src\kxs-ultraedit-x64.22.20.nupkg
8>          1 file(s) moved.
3>  This is try 1/3. Retrying after 300 milliseconds.
3>EXEC : Error converted to warning : 
3>   The process cannot access the file 'C:\ProgramData\chocolatey\config\chocolatey.config.update' because it is being used by another process.
3>  Attempting to build package from 'kxs-tortoisesvn-x64.nuspec'.
3>  Successfully created package 'kxs-tortoisesvn-x64.1.7.10.23359.nupkg'
3>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
3>  E:\devops\development\Chocolatey\packages\kxs-tortoisesvn64\src\kxs-tortoisesvn-x64.1.7.10.23359.nupkg
3>          1 file(s) moved.
9>  Attempting to build package from 'kxs-ultracompare.nuspec'.
9>  Successfully created package 'kxs-ultracompare.1.7.7.nupkg'
9>  Moving package to \\corpstor1\software\DevOps\Chocolatey\packages\...
9>  E:\devops\development\Chocolatey\packages\kxs-ultracompare\src\kxs-ultracompare.1.7.7.nupkg
9>          1 file(s) moved.
========== Build: 9 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
ferventcoder commented 8 years ago

For the most part the Feature template is at the bottom of that (and it mentions a blank slate).

Apteryx0 commented 7 years ago

Isn't this as simple as:

diff --git a/src/chocolatey/infrastructure/services/XmlService.cs b/src/chocolatey/infrastructure/services/XmlService.cs
index 00619f6..032e87d 100644
--- a/src/chocolatey/infrastructure/services/XmlService.cs
+++ b/src/chocolatey/infrastructure/services/XmlService.cs
@@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.services
     using System.Text;
     using System.Xml;
     using System.Xml.Serialization;
+    using System.Diagnostics;
     using cryptography;
     using filesystem;
     using tolerance;
@@ -65,7 +66,7 @@ namespace chocolatey.infrastructure.services
         {
             _fileSystem.create_directory_if_not_exists(_fileSystem.get_directory_name(xmlFilePath));

-            var xmlUpdateFilePath = xmlFilePath + ".update";
+            var xmlUpdateFilePath = xmlFilePath + ".update" + Process.GetCurrentProcess().Id().ToString();

             FaultTolerance.try_catch_with_logging_exception(
                 () =>
ferventcoder commented 7 years ago

Possibly - what happens in the case of multiple update files though?

ferventcoder commented 7 years ago

Similar work for this is in #1258, and there is a PR for that, so we will close this as a duplicate. Follow along on 1258 for updates. Thanks!

TheCakeIsNaOH commented 2 years ago

Removing from milestone as a duplicate