IT story

솔루션에서 nuget 패키지 복원을 제거

hot-time 2020. 6. 13. 09:43
반응형

솔루션에서 nuget 패키지 복원을 제거


'NuGet 패키지 복원 사용'을 사용하여 솔루션에 최근 nuget 패키지 복원 기능을 추가했습니다. http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

그러나 빌드 서버가 손상되어 해결할 시간이 없었으므로 제거하고 싶었습니다. 내가 아는 한 그에 대한 옵션은 없으므로 모든 * .csproj 파일에서 다음 줄을 수동으로 제거했습니다.

<Import Project="$(SolutionDir)\.nuget\nuget.targets" />

문제는 이제 내 * .csproj 파일을 체크 아웃하거나 솔루션을 열 때마다 라인이 자동으로 다시 추가되어 실수로 파일을 체크인하면 빌드가 손상된다는 것입니다.

영구적으로 제거하는 방법에 대한 아이디어가 있습니까?

업데이트 : 아래의 답변에도 불구하고 솔루션을 열 때 여전히 같은 문제가있는 사람이 계속 다시 나타납니다.


잘 보지 못했습니다. 프로젝트 파일에 다른 속성이 추가되었습니다.

<RestorePackages>true</RestorePackages>

모든 * .csproj 파일에서이 행과 모든 행을 수동으로 제거하면됩니다.

  <Import Project="$(SolutionDir)\.nuget\nuget.targets" />

최신 정보:

프로젝트 파일을 수동으로 편집 하는 경우 솔루션을 닫고 한 번에 프로젝트에서 모든 줄을 삭제했는지 확인하십시오 . 그렇지 않으면 프로젝트가 다시로드되면 다시 추가됩니다 ...

UPDATE2 :

솔루션 루트에서 .nuget 폴더도 삭제하십시오.

업데이트 3 :

이후 버전의 NuGet은 제거해야 할 다른 섹션을 추가합니다.

 <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
  </Target>

업데이트 4

내부 NuGet.Targets에있는 .nuget폴더 허위로 전환 ... 새로운 프로젝트에 추가됩니다 다른 섹션이있다.

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'false'">
    RestorePackages;
    $(BuildDependsOn);
</BuildDependsOn>

Nuget 패키지 복원을 비활성화하려면 :

  1. .nuget 폴더 삭제
  2. 모든 .csproj 파일에서 특정 줄 제거

제거 할 줄 :

<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<RestorePackages>true</RestorePackages>

참고 : 솔루션을 다시로드하기 전에 한 번에 모든 변경 사항을 수행해야합니다. 그렇지 않으면 변경 사항이 다시 추가됩니다.

이는 다음 기사를 기반으로합니다. http://bartwullems.blogspot.no/2012/08/disable-nuget-package-restore.html

또한이 옵션이 비활성화되어 있는지 다시 확인하고 싶을 수도 있습니다. http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages


이 설정이 아닌가요?

옵션 ...- > Nuget 패키지 관리자 -> [선택 취소] Nuget이 누락 된 패키지를 다운로드하도록 허용

여기에 이미지 설명을 입력하십시오

Visual Studio Professional + Resharper 8.2를 사용하고 있습니다.


현재 MSBuild 통합 패키지 복원을 사용하는 솔루션을 자동 패키지 복원으로 마이그레이션 할 수 있습니다. 내가 이해 한 바에 따르면 CI 빌드 문제가 발생하는 사람들에게 도움이 될 것입니다. (실수하면 정정하십시오).

nuget 웹 사이트 ( http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore) 에서 자동 패키지 복원을 사용하기 위해 MSBuild 통합 솔루션 마이그레이션 문서를 참조하십시오.

TFS를 사용하거나 사용하지 않고 변환하기위한 정보가 있습니다.

David Ebbo는 http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html에 정보를 게시했습니다.


우리는 실제로 그것에 관한 블로그 게시물을 가지고 있으며 게시물 끝에는 마이그레이션을 돕기 위해 powershell 스크립트가 언급되었습니다.

http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore


NuGet has a blog post about migrating to automatic package restore: http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore

There is a powershell script referenced in the blog post that will take care of removing the necessary lines automatically (and recursively): https://github.com/owen2/AutomaticPackageRestoreMigrationScript/blob/master/migrateToAutomaticPackageRestore.ps1

Offering a Disable NuGet Package Restore option directly is marked as Won't Fix: https://nuget.codeplex.com/workitem/1883


I followed the accepted solution to no avail using 2012. This did work though,

  1. Completely close the VS
  2. Update the <RestorePackages>true</RestorePackages> to <RestorePackages>false</RestorePackages> and delete the <Import Project="$(SolutionDir)\.nuget\nuget.targets" /> line
  3. Also renamed the nuget.exe to nuget.exe.NotExe

For anyone still needing to clean up a project using the old style NuGet package restore, the IFix tool available here automates the process.

Just run the installer (IFix will be added to PATH) and then run the following:

IFix nugetrestore --fix

You can run it in check mode first to see what it will clean up:

IFix nugetrestore --check

I had the same issue. What I ended up doing: 1) go into each project .csproj file in the solution, open it in notepad then removed the portion of the xml and saved.

2)Then I removed the all of the package.config files in the entire solution.

3)Then I had to remove the .nuget and package folders.

At this point, I had a completely NuGet free solution.

4)Then I manually referenced any needed DLLs and hit compile and the solution ran like a champ without the NuGet packages being needed.


Go to your solution directory where you have [$(SolutionDir)\.nuget\nuget.targets] .nuget folder and nuget.targets file under it delete the folder, and change remove lines from your csproj for once last time.

The problem won't come back to bug you again.


Remove the packages.config file within your solution.


I accidentally enabled this "package restore" option while opening my project in VS2012 RC and started getting errors that looked something like:

"Error 1 Unable to locate 'C:\FolderX\SomeProject.nuget\nuget.exe'"

To fix the error I followed the above instructions, opened open each project file in notepad and removed that RestorePackage line.


I was able to resolve this issue by taking these steps:

1) make sure you take a backup of all your current checked-out files changes.

2) physically delete the solution folder from your C:\ (path that is mapped to TFS).

3) get latest from TFS for your solution.

4) copy (if any) your changes from the backup you took in step-1.

hope that helps !


I ran into the exact same problem and tried to remove all .nuget and RestorePackage tags from the project files but one project just wouldn't reload not matter how thoroughly I examined it for .nuget and RestorePackages tags. I guess there's some hidden references to this somewhere.

In the end it was easier to just copy the files and create a new project and import it to the solution.


Nuget sucks. Just remove nugets and remove or comment package elements from packages.config in root directory of the projects where this is a problem. Use direct references into some lib folder instead.

<?xml version="1.0" encoding="utf-8"?>
  <packages>
    <!--<package id="EntityFramework" version="6.0.2" targetFramework="net45" />-->
  </packages>

참고 URL : https://stackoverflow.com/questions/8713616/remove-nuget-package-restore-from-solution

반응형