首页 > 解决方案 > Visual Studio Nuget 安装 'app.config 正在使用中'

问题描述

我似乎无法在我的 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#visual-studionuget

解决方案


您可以按照此问题中的解决方法来确定哪个文件占用了文件。

也试试:

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

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

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

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


推荐阅读