NuGet Cehennemi

NuGet bize ciddi kolaylık sağlıyor. Ancak projeler arttıkça her proje için “packages” folderının aldında gerekli paketleri indirmesi gerekiyor. Bunun önüne geçmek için “.nuget” klasörü içinde bulunan “NuGet.Config” dosyasını güncellememiz gerekiyor.


<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="D:\_SourceCode\Packages" />
</config>
</configuration>

Bu düzenlemeyi yaptıktan sonra artık projelerimiz patketlerini burada bildirilen dizin altında arayacaklardır.

Ancak bir diğer sıkıntıda projelerimizin yerini değiştirdiğimizde karşımıza çıkar

Bunlardan ilki “missing nuget.target error ”

Bunun düzeltmek için ilgili proje dosyası örneğin .csproj içinde gerekli düzenlemeleri yapmak lazım


<Import Project="D:\_SourceCode\.nuget\NuGet.targets" Condition="Exists('D:\_SourceCode\.nuget\NuGet.targets')" />
<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('D:\_SourceCode\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', 'D:\_SourceCode\.nuget\NuGet.targets'))" />
</Target>

Diğeri “unable to locate nuget.exe. Bunun için .nuget dizini içindeki nuget.targets dosyasında şu güncellemeyi yapmalıyız.

Dosya içinde “NUGETEXEPATH” kelimesini aratalım ve aşağıdaki satırı nuget.exe’nin yolu ile güncelleyelim


<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">d:\_SourceCode\.nuget\NuGet.exe</NuGetExePath>

Bir de son packages folderında “repositories.config” diye bir dosyamız var. Bu da projelerin altındaki packages.config dosyalarının yollarını içeriyor. Burada her bir proje için doğru yolun verilmiş olması gerekiyo.

This project references NuGet package(s) that are missing on this computer.

Bu işlemleri yaptıktan sonra NuGet uygulamasini bir miktar dağıttığımız için diğer projelerde de bu hata mesajı gelebilir.

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 D:\_SourceCode\Weblebici\Iyonsis.Services\\.nuget\NuGet.targets.
Iyonsis.Services    D:\_SourceCode\Weblebici\Iyonsis.Services\Iyonsis.Services.csproj    375

Hata mesajında sondaki rakam csproj dosyasındaki satır numarası.

  <Import Project=”$(SolutionDir)\.nuget\NuGet.targets” Condition=”Exists(‘$(SolutionDir)\.nuget\NuGet.targets’)” />
<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>

Yani gidiyor solution altında nuget dosyalarını arıyor bulamıyor. Buradaki tüm relative pathleri absolute olanlar ile nuget dosyalarını  gosterecek şekilde tekrar değiştirdim.

<Import Project=”D:\_SourceCode\.nuget\NuGet.targets” Condition=”Exists(‘D:\_SourceCode\.nuget\NuGet.targets’)” />

<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(‘D:\_SourceCode\.nuget\NuGet.targets’)” Text=”$([System.String]::Format(‘$(ErrorText)’, ‘D:\_SourceCode\.nuget\NuGet.targets’))” />
</Target>

Yazı oluşturuldu 141

Benzer yazılar

Aramak istediğinizi üstte yazmaya başlayın ve aramak için enter tuşuna basın. İptal için ESC tuşuna basın.

Üste dön