【问题标题】:Visual Studio Nuget install 'app.config is in use'Visual Studio Nuget 安装 'app.config 正在使用中'
【发布时间】:2019-10-02 10:16:36
【问题描述】:

我似乎无法在我的 C# 类库中安装 nuget 包 Oracle.ManagedDataAccess 18.3.0.0。

每当我尝试安装它时,它都会引发以下错误:

System.IO.InvalidDataException: An error occurred while applying transformation to 'App.config' in project 'MyClassLibrary' The process cannot access the file 'R:\DEV\MyClassLibrary\App.config' because it is being used by another process. ---> System.IO.IOException: The process cannot access the file 'R:\DEV\MyClassLibrary\App.config' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at NuGet.ProjectManagement.FileSystemUtility.CreateFile(String fullPath)

当我在尝试安装 nuget 之前删除 app.config 时,它将在安装 nuget 期间重新创建它,并且此错误仍然存​​在。它拒绝安装。

AFAIK 没有其他进程在运行。重新启动后,同样的问题仍然存在。

我正在使用 Visual Studio 2017 Pro。可能是什么问题?

【问题讨论】:

  • 您的项目似乎不在解决方案目录下,您可以在默认的 `C:\Users\xxx\source\repos` 下新建一个项目来检查此问题是否仍然存在。

标签: c# visual-studio nuget


【解决方案1】:

您可以关注workarounds in this issue 来确定是哪个文件占用了文件。

也试试:

1.卸载当前项目中的那个包

2.Tools=>Nuget 包管理器=>包管理器设置=>清除所有 nuget 缓存

3.导航到项目目录,删除bin和obj文件夹。如果存在,也删除解决方案目录中的包文件夹。

4.然后以管理员身份启动VS安装包,我建议你可以通过Nuget包管理器UI安装它。

【讨论】:

  • 我已经尝试了这些步骤,除了以管理员身份启动。由于这是一台工作 PC,而且它是一个安全的环境,我没有可用的管理员权限。因此,链接问题中的解决方案也是不可能的,因为它们需要管理员权限。但是,由于 VS 在安装 nuget 时创建文件,我可以相对确定没有其他程序占用它...
  • 您好,如果您在新解决方案中创建一个新的空类库并使用该包,同样的问题仍然存在?
  • 是的。它似乎是 Oracle.ManagedDataAccess.EntityFramework。然而。再次点击安装4次后,它通过了
  • @Bjorn 很高兴知道它现在可以工作了,如果您能找到问题的原因和那天的解决方法,别忘了将其添加为答案:)
猜你喜欢
  • 1970-01-01
  • 2017-04-02
  • 2018-04-01
  • 1970-01-01
  • 2017-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多