X tool custom template

Hi is possible to create a custom template to consume with the x tool from a private repository?

You can customize it to create templates referencing a different public organization but not from a private repo.

Can look into adding support for something like that.

I was trying to check the source code for the X tool but when i try to run the pack.bat i get the following message, never seen this error, have any idea?

C:\Program Files\dotnet\sdk\3.1.101\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): 
error : The DateTimeOffset specified cannot be converted into a Zip file timestamp. 
(Parameter 'value') [C:\Users\sebas\dev\src\dotnet-app\src\X\X.csproj]

Are you looking at the right repo? https://github.com/ServiceStack/dotnet-app

There’s no external deps so you should be able to pull latest from master and run. I’ve just tried again, clearing my local NuGet packages cache so it’s running the latest version:

$ nuget locals all -clear

Then ran pack.bat which builds as expected:

Microsoft Windows [Version 10.0.18362.719]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\src\dotnet-app\src\X>pack.bat

C:\src\dotnet-app\src\X>dotnet pack X.csproj -c release -o nupkg
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 10.81 sec for C:\src\dotnet-app\src\X\X.csproj.
C:\src\dotnet-app\src\Web\Startup.cs(2199,56): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' [C:\src\dotnet-app\src\X\X.csproj]
C:\src\dotnet-app\src\Web\Startup.cs(2055,9): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' [C:\src\dotnet-app\src\X\X.csproj]
C:\src\dotnet-app\src\Web\Startup.cs(2056,24): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' [C:\src\dotnet-app\src\X\X.csproj]
  X -> C:\src\dotnet-app\src\X\bin\release\netcoreapp3.1\x.dll
  X -> C:\src\dotnet-app\src\X\bin\release\netcoreapp3.1\x.dll
  Successfully created package 'C:\src\dotnet-app\src\X\nupkg\x.0.0.5.nupkg'.
C:\Program Files\dotnet\sdk\3.1.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5125: The 'licenseUrl' element will be deprecated. Consider using the 'license' element instead. [C:\src\dotnet-app\src\X\X.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl [C:\src\dotnet-app\src\X\X.csproj]

C:\src\dotnet-app\src\X>

You can also run install-local-tool.bat to build & install the X tool and have it replace your existing x tool installed from NuGet, which also appears to be working, e.g:

C:\src\dotnet-app\src\X>install-local-tool.bat

C:\src\dotnet-app\src\X>dotnet pack X.csproj -c release -o nupkg
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 109.59 ms for C:\src\dotnet-app\src\X\X.csproj.
  X -> C:\src\dotnet-app\src\X\bin\release\netcoreapp3.1\x.dll
  X -> C:\src\dotnet-app\src\X\bin\release\netcoreapp3.1\x.dll
  Successfully created package 'C:\src\dotnet-app\src\X\nupkg\x.0.0.5.nupkg'.
C:\Program Files\dotnet\sdk\3.1.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5125: The 'licenseUrl' element will be deprecated. Consider using the 'license' element instead. [C:\src\dotnet-app\src\X\X.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl [C:\src\dotnet-app\src\X\X.csproj]

C:\src\dotnet-app\src\X>dotnet tool uninstall -g x
Tool 'x' (version '0.0.5') was successfully uninstalled.

C:\src\dotnet-app\src\X>dotnet tool install --add-source .\nupkg -g x
You can invoke the tool using the following command: x
Tool 'x' (version '0.0.5') was successfully installed.

C:\src\dotnet-app\src\X>

Yes i have the correct repository, and cleared the caches
I have also tried to download .100 sdk version and cloned again the repo same issue.
Also tried to download as a zip.
Maybe something that is happening locally to my windows box.

It seem is an dotnet issue for time zones higher GMT+0

I have managed to build it by following the snippet inside the issue

dotnet publish
Get-ChildItem -File -Recurse | % {$_.LastWriteTime = (Get-Date)}
dotnet pack --no-build

Ok I’ve just added support for being able to create templates from any repo by specifying user/repo as the template name and to be able to access a private repo you’ll need to either specify your GitHub Access Token with the -token argument, e.g:

$ x new user/repo TheProject -token {GITHUB_TOKEN}

Alternatively you can leave specifying the -token if you have your GitHub AccessToken in your GITHUB_TOKEN Environment variable.

I’ve just published v0.0.6 release of the x dotnet tool to NuGet, can usually take them a little while before their indexing makes the latest v0.0.6 available to download, but when it’s ready you’ll be able to download it with:

 $ dotnet tool update -g x

This release also lets you install directly from a URL archive, e.g:

$ x new https://github.com/{user}/{repo}/archive/master.zip TheProject

Which you can use to install any previous release version.

Wow amazing thanks i will try it when is available.
Thanks for the quick support

1 Like

Hi, tried but its not working.
I have taken a look with fiddler, and apparently is correctly listing the repo from api and
but the call to get the zipball dosent have the token specified on the headers.
copying the same call on postman with the addition of the token and the zipball is retrieved correctly

I dont know if i’m looking at the right place but seem the DownloadFile call on the Gateway dosent specify the token

   public virtual void DownloadFile(string downloadUrl, string fileName)
        {
            var webClient = new WebClient();
            webClient.Headers.Add(HttpHeaders.UserAgent, UserAgent);
            webClient.DownloadFile(downloadUrl, fileName);
        }

from https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Common/GitHubGateway.cs

Ok yep apologies, should be resolved with the latest v0.0.7 on NuGet

1 Like

Thanks again, now is working fine just managed to create from my repo

1 Like