Nuget: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 82: Line 82:
* [https://stackoverflow.com/questions/33672930 How to publish ASP.NET Core app over FTP server]
* [https://stackoverflow.com/questions/33672930 How to publish ASP.NET Core app over FTP server]
* [https://docs.microsoft.com/en-us/azure/devops/artifacts/nuget/publish?view=azure-devops Publish a NuGet package from the command line]
* [https://docs.microsoft.com/en-us/azure/devops/artifacts/nuget/publish?view=azure-devops Publish a NuGet package from the command line]
* [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings Custom date and time format strings]
* [https://www.meziantou.net/how-to-publish-a-dotnet-global-tool-with-dotnet-core-2-1.htm How to publish a dotnet global tool]
* [https://www.meziantou.net/how-to-publish-a-dotnet-global-tool-with-dotnet-core-2-1.htm How to publish a dotnet global tool]
* [https://garywoodfine.com/creating-nuget-package-net-core/ Create nuget package .net core]
* [https://garywoodfine.com/creating-nuget-package-net-core/ Create nuget package .net core]

Revision as of 11:01, 12 July 2019

Mono Nuget

brew install mono
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
'alias nuget="mono /usr/local/bin/nuget.exe"' >> ~/.bash_profile
brew uninstall mono
sudo rm -rf /usr/local/bin/nuget.exe
# vim  ~/.bash_profile and delete 'alias nuget="mono /usr/local/bin/nuget.exe"'
nuget setapikey 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a
nuget setapikey 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -source https://cdn.chorke.org/feed

Utility Project

mkdir Utility; cd Utility

dotnet new classlib -n Chorke.Academia.Core.Utility
dotnet new xunit -n Chorke.Academia.Core.Utility.Tests

dotnet new sln -n Utility
dotnet sln add Chorke.Academia.Core.Utility/Chorke.Academia.Core.Utility.csproj

cd Chorke.Academia.Core.Utility.Tests/
dotnet add reference ../Chorke.Academia.Core.Utility/Chorke.Academia.Core.Utility.csproj
cd ..; dotnet sln add Chorke.Academia.Core.Utility.Tests/Chorke.Academia.Core.Utility.Tests.csproj
using System;
using System.Globalization;

namespace Chorke.Academia.Core.Utility
{
    public class DateUtil
    {
        public const string DD_MM_YYYY = "dd/MM/yyyy";

        public static string Format(DateTime date) => Format(date, DD_MM_YYYY);
        public static string Format(DateTime date, string format) => date.ToString(DD_MM_YYYY);

        public static DateTime Parse(String date) => Parse(date, DD_MM_YYYY);
        public static DateTime Parse(String date, string format) => DateTime.ParseExact(date, format, CultureInfo.InvariantCulture);
    }
}
using System;
using Xunit;
using Chorke.Academia.Core.Utility;

namespace Chorke.Academia.Core.Utility.Tests
{
    public class DateUtilTest
    {
        [Fact]
        public void FormatTest()
        {
            DateTime date = new DateTime(1983, 10, 10);
            String actual = DateUtil.Format(date, DateUtil.DD_MM_YYYY);
            Assert.Equal("10/10/1983", actual);
        }
    }
}
dotnet publish Chorke.Academia.Core.Utility
dotnet test Chorke.Academia.Core.Utility.Tests
dotnet publish Chorke.Academia.Core.Utility.Tests

References