I would want to make private NuGet packages referred, and I surveyed it. I wrote down the result here in case I forgot.
Entire the repository isn't concerned with this article so much, but I hope this will help you with how to write Nuget.config.
- By some means, arrange a server in order to put your private Nuget package.
- Buy a MyGet license.
- Use VSTS private feed.
- Using VPS or cloud service, construct a server by myself.
- Put a Nuget.config file in the same folder as .sln.
- Setting environment variables on App Center.
It is OK to skip over this section.
First of all, I tried to use MyGet. But I gave up it because of using private feed in MyGet is not free.
Secondly, I tried to construct a nuget server using nuget.service package. But I gave up it because it did not correspond to ASP.NET core.
Then, I searched "nuget linux" with Google and hit the following site.
And I found the docker image which corresponds to this.
I tried to use it.
But it didn't work well. So I forked those projects and did trial and error.
The result is the following links.
Though I registered docker hub and that is available, it is just a suggestion because I hardly know docker knowledge.
Create a Nuget.config file in the same folder as .sln and write as the following code.
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget" value="https://www.nuget.org/api/v2" /> <add key="MyNuget" value="https://mynuget.com" /> </packageSources> <activePackageSource> <add key="All" value="(Aggregate source)" /> </activePackageSource> <packageSourceCredentials> <MyNuget> <add key="Username" value="%private_nuget_user%" /> <add key="ClearTextPassword" value="%private_nuget_pass%" /> </MyNuget> </packageSourceCredentials> </configuration>
Though I referred from this, I changed default feed URL to VS for Mac default URL because it didn't work for some reason.
Add a private nuget server key-value (name / URL) to packageSources, and add the same name item as added key to packageSourceCredentials. and add user and password item there.
Parts of between % are environment variables which are set in AppCenter. Not to mention, they can be written directly there too.
All you have to do is register environment variables corresponding to the Nuget.config on App Center.
If build success, the following log will begin to be output soon.
But if any settings were made mistake, the following error messages will be displayed and it will take a long time to build.
"Unable to load the service index for source…"
"Package 'something' is not found on source…"
If these messages were shown, you should cancel the build since it will be failed.