BaGet
BaGet copied to clipboard
Read-through caching isn't working
It seems to be, that read-through caching is not working at all. My BaGet v0.3.0-preview5 is installed over IIS on Windows Server 2012 with netcore hosting bundle.
appsettings.json contains following:
"Mirror": {
"Enabled": true,
// Uncomment this to use the NuGet v2 protocol
//"Legacy": true,
"PackageSource": "https://api.nuget.org/v3/index.json"
}
Everything works fine except read-through caching - I can't install or restore any package if it was not previously pushed to BaGet, neither with nuget.exe nor dotnet CLI, getting error: NU1101
.
For example:
nuget install EasyCaching.InMemory -Version 1.2.0 -Source http://***-***.***.***/v3/index.json
Returns:
Package 'EasyCaching.InMemory 1.2.0' is not found in the following primary source(s): 'http://***-***.***.***/v3/index.json'. Please verify all your online package sources are available (OR) package id, version are specified correctly.
What is expected behavior with read-through caching? As I suppose, if there is no package on local server, it should search forward on nuget.org, and automatically cache package if it was found?
I tried to uncomment "Legacy" line and/or change source to nuget.org/v2 - with no results.
Is there something I misunderstand? Wondering, what I'm doing wrong.
Found this reply from @fourpastmidnight , so it makes me think, that problem is reproducable.
Thanks for any help.
I am facing the same issue. When I run the Baget from command line using dotnet Baget.dll, when I update a package from Visual studio for example it downloads the package and index it locally. When I add the Baget in IIS then it does not do anything... Also the search is not working in both environments, either running from command or from IIS. When I am trying to search for a package that does not exists locally, e.g. Newtonsoft, it looks like does not search the nuget.org api and does not return any results.
Read through caching doesn't work for me, either. Everything else works great. Is there a patch that fixes read through caching?
I'm running the latest version: v0.4.0-preview2. On a Windows server VM with appsettings.json configuration changes (for read-through), from here: https://loic-sharma.github.io/BaGet/configuration/
I've searched through old issues and this problem appears to have been solved, before. Is there additional configuration to make this function?
Thanks!
Lee
Weird, I'm not able to reproduce this issue. Could you try increasing the console log level to Debug
and sharing any exceptions or errors you see in the logs?
Here's how to update your configs to increase the console log level to Debug
:
{
...
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Microsoft.Hosting.Lifetime": "Information",
- "Default": "Warning"
+ "Default": "Debug"
}
}
}
}
doesn't work for me also
Can you explain how it should work?
I've added baget address as new nuget source in Visual Studio, when I select nuget.org as a source it can successfully find let's say Nlog package:
If I select Baget as a source it can't find:
When I try to install package explicitly as topic starter I get the same error:
nuget install NLog -Version 4.7.1.3 -Source http://my.baget.address:8081/v3/index.json
Feeds used:
<local package folder>
http://my.baget.address:8081/v3/index.json
Attempting to gather dependency information for package 'NLog.4.7.1.3' with respect to project '<ProjectPath>', targeting 'Any,Version=v0.0'
Package 'NLog 4.7.1.3' is not found in the following primary source(s): '<local package folder>,http://my.baget.address:8081/v3/index.json'. Please verify all your online package sources are available (OR) package id, version are specified correctly.
There are no errors/exceptions in console logs even if I enable Debug logs.
During remote debugging I found out, that our host server, where BaGet is hosted, has some certificates issues, so all attempts to get list of packages from api.nuget.org fail with corresponding exceptions, because of untrusted cert.
Meanwhile, I couldn't get any logs from BaGet, cause IIS redirects all console output to nullstream.
I'll try to reproduce the problem, when security issues will be resolved, but almost sure, that it'll be ok.
i have configed the appsetting.json but it's not work
I turned up logging, but can't locate where the logging target outputs log files. That doesn't seem configurable in this version. Is there more to the setup instruction to choose a specific logging file target path?
I turned up logging, but can't locate where the logging target outputs log files. That doesn't seem configurable in this version. Is there more to the setup instruction to choose a specific logging file target path?
hi~ i known how it works 。 actually, it's works。 at first , i think when i search in index page, if local dosen't exit the package, then it will research to the nuget.org api and return for me. but No! it will only search the nuget.org by xxx/search/ be called.
how to call the xxx/search ? open your virtural studio ,and right click your project and left click the 'manager nuget pacages' find the package source and add our private source (if you don't known how to add a package source ,you can google it, so easy)
then , chose the 'all' and install a pacakage ,like 'Newtonsoft.Json' by version 9.0.1 then , chose the 'your private source' which you add just now, then , click the installed tab you can find the 'Newtonsoft.Json' has a new version button , update it then , open the baget adress ,you will find 'Newtonsoft.Json' appeared
all other package can do like this,
i call this action 'give baget a seed, then it will load'
finally , i hope baget will search the mirror__PackageSource address eveytime when i searched. then i can get the pacakage which local not exit more easy.
author do not do this 'merge' (i call this action 'merge' which merge the local result and remote result . lol ),maybe has his own considerations.
hope this advice can help you .
Read-though caching is not working for me too
Read-though caching is working for me and it's quite good feature but I must have build the code myself and deploy it this way. The official docker version does not work properly, it fails with strange PostgreSQL error.
This is a working docker-compose.yml with Traefik as proxy and basic authentication
version: '3.3'
services:
baget-nuget-server:
build: "./build/"
networks:
- traefik
volumes:
- ./data:/var/baget
# ports:
# - 8000:80
env_file:
- ./.env
labels:
- traefik.enable=true
# Public
- traefik.http.routers.baget-nuget-server.rule=Host(`nuget.ourserver.com`)
- traefik.http.services.baget-nuget-server.loadbalancer.server.port=80
- traefik.http.routers.baget-nuget-server.service=baget-nuget-server
- traefik.http.routers.baget-nuget-server.tls=true
- traefik.http.routers.baget-nuget-server.tls.certresolver=le
- traefik.http.routers.baget-nuget-server.entrypoints=websecure
- traefik.http.routers.baget-nuget-server.middlewares=baget-nuget-server-auth
- traefik.http.middlewares.baget-nuget-server-auth.basicauth.headerField=X-WebAuth-User
- traefik.http.middlewares.baget-nuget-server-auth.basicauth.usersfile=./etc/traefik/userfiles/baget.users
networks:
traefik:
external: true
build
folder contains whole src
folder and Dockerfile
.env
file looks like this, with Debug logging and very strange property Storage__Path that I did not find in code but it still works :-)
ApiKey=xxxxxxxxxxxxxxxxx
PackageDeletionBehavior=HardDelete
AllowPackageOverwrites=true
Storage__Type=FileSystem
Storage__Path=/var/baget
Database__Type=PostgreSql
Database__ConnectionString=Server=our-postgresql-server;Port=5432;Database=baget_nuget_server;User Id=baget_nuget_server;Password=Our baget very secure password;
Search__Type=Database
Mirror__Enabled=true
Mirror__PackageSource=https://api.nuget.org/v3/index.json
Logging__Console__LogLevel__Default=Debug
To use it in a Dockerfile of some other project you need to do this https://stackoverflow.com/a/76177774/5556714
Result
Well it works, but in a bit of a different way the most people expect.
Nothing is displayed in web ui search, cause search request hits only internal database and is not redirected to PackageSource
in appsettings.json.
Principle is the same, so here's explanation for Visual Studio:
- make sure nuget.org package source is present and enabled.
- enable read-through as described in the docs
- In Visual Studio add package source to BaGet server
- move BaGet package source above the nuget.org package source
Here's how it looks in NuGet.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="BaGet" value="http://dev-server:5000/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
- In 'NuGet Package Manager' set 'Package source' to 'All'
- enter a query in the search box, select a required package and click 'Install'
Only now if the requested package is missing on a BaGet server it will be downloaded from the
PackageSource
- To verify that the package is present on the BaGet server, select your BaGet source in 'Package source' drop down In 'NuGet Package Manager' or open BaGet web ui.
Hope this helps.
does this work also with nuget v2 or just v3? (read through mirror cache), I wasn't able to get results. would be great if also indexing worked... or if baget could just background cache locally and mirror an external source, without having to specify that in nuget.config in the client
Hi everyove. Read-through work if you set two settings in Environment(not appsetings.json) Mirror__Enabled=true Mirror__PackageSource=https://api.nuget.org/v3/index.json