2018年4月12日 星期四

[ProGet] Installation tips and Setup (NuGet)


  ProGet    Nuget Package  




Introduction


We will learn some tips for installing and setting ProGet and upload first nuget package to it.



Environment


ProGet 5.0.11
Windows Server 2008 R2



Installation


Download



Install

Before you start the installation, create a new database in SQL Server.
Run the .exe and follow the official installation guide.




Trouble shooting

When installing ProGet, I encountered the following error.

The database could not be exclusively locked to perform the operation.
ALTER DATABASE failed. Cannot set database XXX’s default collation as SQL_Latin1_General_CP1_CI_AS

System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   Inedo.ProGet.Setup.InstallProGetTask.CheckCreateDB()
   Inedo.ProGet.Setup.InstallProGetTask.Install()
   Inedo.Installer.InstallationTask`1.Inedo.Installer.IInstallationTask.RunInternal()
ClientConnectionId:59abd9f0-3013-4b14-be74-1f8e3344e424
Error Number:5030,State:2,Class:16






One of the solution is to set the database to single user manually.

ALTER DATABASE [Your_DbName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE


PS. Don’t forget to set it back as MULTI_USER after installation.

ALTER DATABASE [Your_DbName] SET MULTI_USER WITH ROLLBACK IMMEDIATE



However, it didn’t work for me.
I finally solved this issue by manually executing the ALTER DATABASE sql like this,

ALTER DATABASE [DbName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

ALTER DATABASE [DbName]
COLLATE SQL_Latin1_General_CP1_CI_AS ;
GO

ALTER DATABASE [DbName] SET MULTI_USER WITH ROLLBACK IMMEDIATE


Done!




Setup and upload a NuGet package



Setup

Now open http://server-name:8624 and login as Admin. (Default ID/PWD: Admin/Admin)


Then create a new Feed



Select NuGet as following.



For more information about setting the Feed, see document.


Since we have a Feed, create an api key for it.







Upload a nupkg package

Use either of the following ways to upload a NuGet package.

2.      NuGet CLI

NuGet Package Explorer

FILEPublish

Publish Url: http://server-name/nuget/Feed-name/
Publish key: The API key




NuGet CLI

$ nuget push MyPackage.nupkg -ApiKey XXXXXXXXX -source http://server-name/nuget/Feed-name/



Now you can add the NuGet package Feed (http://server-name/nuget/Feed-name/)
into Visual Studio: Package Sources.


Enjoy it!



Reference





沒有留言:

張貼留言