Skip to content

Commit

Permalink
Merge pull request #2 from piraces/next
Browse files Browse the repository at this point in the history
Next version for dotnex: stable 1.0.0
  • Loading branch information
piraces authored Jan 30, 2022
2 parents 9fb6951 + 7a4881c commit 5017db2
Show file tree
Hide file tree
Showing 28 changed files with 550 additions and 55 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: .NET Docs publish

on:
push:
branches: [ main ]

jobs:
publish:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
- name: Install docfx via Chocolatey
run: choco install docfx -y
- name: Install docfx via Chocolatey
run: choco install docfx -y
- name: Generate documentation
run: cd docs; docfx .\docfx.json --build
- name: Deploy to Github Pages
uses: crazy-max/ghaction-github-pages@v2
with:
build_dir: docs/_site
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Pack
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: .NET CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
# - name: Test
# run: dotnet test --no-build --verbosity normal
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,13 @@ MigrationBackup/
.ionide/

# JetBrains IDEs
.idea/
.idea/

/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
/**/docs/doc/*.yml
/**/docs/doc/.manifest
9 changes: 7 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<Project>
<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.0-beta-20204-02" />
<PackageReference Update="System.CommandLine" Version="2.0.0-beta1.20574.7" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageReference Update="System.CommandLine" Version="2.0.0-beta2.21617.1" />
<PackageReference Update="FluentAssertions" Version="6.4.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Update="xunit" Version="2.4.1" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Update="coverlet.collector" Version="3.1.0" />
</ItemGroup>
</Project>
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This simple tool provides the minimum necessary to run dotnet tools without the

- **SourceLink for debugging**. The binaries can be debbuged with [Source Link](https://github.com/dotnet/sourcelink). Example (with Developer Command Prompt for VS): `devenv /debugexe c:\Users\rich\.dotnet\tools\dotnex.exe`

- **Symbols package**. A symbols package is published too in the publish process in order to ease the debugging of the NuGet package.


## Usage
Expand All @@ -29,14 +30,15 @@ dotnex [options] <TOOL> [<TOOL-ARGS>...]
Where the arguments and options are the following:
```
Arguments:
<TOOL> The NuGet Package Id of the tool to execute
<TOOL-ARGS> Arguments to pass to the tool to execute
<TOOL> The NuGet Package Id of the tool to execute []
<TOOL-ARGS> Arguments to pass to the tool to execute
Options:
-v, --version <version> Version of the tool to use
-f, --framework <framework> Target framework for the tool
-r, --remove-cache Flag to remove the local cache before running the tool (can be run without tool)
-?, -h, --help Show help and usage information
-v, --use-version <use-version> Version of the tool to use
-f, --framework <framework> Target framework for the tool
-r, --remove-cache Flag to remove the local cache before running the tool (can be run without tool)
--version Show version information
-?, -h, --help Show help and usage information
```

This same output can be obtained running the tool with the help option:
Expand All @@ -59,14 +61,19 @@ dotnet tool install -g dotnex

### SDK version

`dotnex` is actually built for .NET 5. The main idea is to maintain `dotnex` up-to-date with the current, most stable release of dotnet recommended to use at the date by Microsoft.
`dotnex` is published for all current supported SDKs from Microsoft:
- .NET Core 3.1.x
- .NET 5.0.x
- .NET 6.0.x

The main idea is to maintain `dotnex` up-to-date with all current supported SDKs from Microsoft.

## Contributions

Feel free to open an issue or a PR if you want to without any problem :)

## License

This project is licensed under the [MIT License](./LICENSE).
This project is licensed under the [MIT License](LICENSE).

See the `LICENSE` file in the root of this repository.
Empty file added docs/apidoc/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions docs/articles/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Introduction

This simple tool provides the minimum necessary to run dotnet tools without the need of installing them globally or in a project, since this is not yet supported in dotnet cli.

It is a similar approach to [npx](https://www.npmjs.com/package/npx) from [npm](https://www.npmjs.com/).

2 changes: 2 additions & 0 deletions docs/articles/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Introduction
href: intro.md
3 changes: 3 additions & 0 deletions docs/doc/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Explore the source code documentation

Click around and find how **dotnex** works!
70 changes: 70 additions & 0 deletions docs/docfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"metadata": [
{
"src": {
"files": [ "**.csproj" ],
"exclude": [ "**/bin/**", "**/obj/**" ],
"src": "../src"
},
"dest": "doc",
"disableGitFeatures": false,
"disableDefaultFilter": false
}
],
"build": {
"content": [
{
"files": [
"doc/**.yml",
"doc/index.md"
]
},
{
"files": [
"articles/**.md",
"articles/**/toc.yml",
"toc.yml",
"*.md"
]
}
],
"resource": [
{
"files": [
"images/**"
]
}
],
"overwrite": [
{
"files": [
"apidoc/**.md"
],
"exclude": [
"obj/**",
"_site/**"
]
}
],
"dest": "_site",
"globalMetadata": {
"_appTitle": "dotnex - Home page",
"_gitContribute": {
"repo": "https://github.com/piraces/dotnex",
"branch": "main"
},
"_appLogoPath": "/images/logo.png",
"_appFaviconPath": "/images/favicon.ico"
},
"fileMetadataFiles": [],
"template": [
"default"
],
"postProcessors": [],
"markdownEngineName": "markdig",
"noLangKeyword": false,
"keepFileLink": false,
"cleanupCacheHistory": false,
"disableGitFeatures": false
}
}
Binary file added docs/images/favicon.ico
Binary file not shown.
Binary file added docs/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Main site for **dotnex**

A simple .NET tool to execute other dotnet tools without installing them globally or in a project (a similar approach to [npx](https://www.npmjs.com/package/npx) from [npm](https://www.npmjs.com/)).

[**View in Nuget.org**](https://www.nuget.org/packages/dotnex/)

This simple tool provides the minimum necessary to run dotnet tools without the need of installing them globally or in a project, since this is not yet supported in dotnet cli.

## Quick Start

Install the [dotnet cli](https://dotnet.microsoft.com/download) (included in the .NET SDK) and then run the following command:

```shell
dotnet tool install -g dotnex
```

Execute your dotnet tool:

```shell
dotnex dotnetsay Easy!!
```
5 changes: 5 additions & 0 deletions docs/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: Articles
href: articles/
- name: Documentation
href: doc/
homepage: doc/index.md
10 changes: 8 additions & 2 deletions dotnex.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
# Visual Studio Version 17
VisualStudioVersion = 17.1.32120.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnex", "src\dotnex\dotnex.csproj", "{48FB0B53-CC53-441D-B41C-CBFACF82A7BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnex.IntegrationTests", "tests\dotnex.IntegrationTests\dotnex.IntegrationTests.csproj", "{0C78E5C4-0656-4C5F-87F0-297AD50C6AA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{48FB0B53-CC53-441D-B41C-CBFACF82A7BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48FB0B53-CC53-441D-B41C-CBFACF82A7BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48FB0B53-CC53-441D-B41C-CBFACF82A7BA}.Release|Any CPU.Build.0 = Release|Any CPU
{0C78E5C4-0656-4C5F-87F0-297AD50C6AA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C78E5C4-0656-4C5F-87F0-297AD50C6AA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C78E5C4-0656-4C5F-87F0-297AD50C6AA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C78E5C4-0656-4C5F-87F0-297AD50C6AA7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 4 additions & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "5.0.102"
}
}
"sdk": {
"version": "6.0.101"
}
}
12 changes: 12 additions & 0 deletions src/dotnex/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@

namespace dotnex
{
/// <summary>
/// Main manager for the dotnet tools cache.
/// It caches tools for subsequent or future executions, avoiding downloading it every time
/// </summary>
public static class CacheManager
{
private const string TEMP_FOLDER_NAME = "dotnex";

private static string _tempFolder = Assembly.GetExecutingAssembly().Location;

/// <summary>
/// Removes all cached tools from the cache temporary folder.
/// </summary>
/// <returns>0 if cache has been cleared successfully. 1 otherwise</returns>
public static int RemoveAllCachedFiles()
{
var tempFolder = GetTempFolder();
Expand All @@ -29,6 +37,10 @@ public static int RemoveAllCachedFiles()
}
}

/// <summary>
/// Gets the temporary folder to store the cache in.
/// </summary>
/// <returns>The current user temp folder or the current directory if the first is not writable/accesible</returns>
public static string GetTempFolder()
{
try
Expand Down
21 changes: 20 additions & 1 deletion src/dotnex/CliCommandLineWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@

namespace dotnex
{
/// <summary>
/// Wrapper around the dotnet cli to execute external tools.
/// </summary>
public class CliCommandLineWrapper
{
private const string DOTNET_CLI_COMMAND = "dotnet";

private readonly Process _toolCliProcess;

/// <summary>
/// Constructor for the CLI wrapper.
/// It takes arguments, if the output should be redirected, the working directory and if the external tool window should be hidden.
/// </summary>
/// <param name="args">Arguments/options to execute the tool with</param>
/// <param name="redirectOutput">If the STDERR/STDOUT should be redirected (default false)</param>
/// <param name="workingDirectory">Working directory to run the tool from (default the current one)</param>
/// <param name="processWindowStyle">ProcessWindowStyle for the CLI execution (default hidden)</param>
public CliCommandLineWrapper(string[] args, bool redirectOutput = false, string? workingDirectory = null, ProcessWindowStyle processWindowStyle = ProcessWindowStyle.Hidden)
{
_toolCliProcess = new Process();
Expand All @@ -26,11 +37,19 @@ public CliCommandLineWrapper(string[] args, bool redirectOutput = false, string?
_toolCliProcess.StartInfo.WorkingDirectory = workingDirectory;
}
}


/// <summary>
/// Starts the CLI command and returns the exit code.
/// </summary>
/// <returns>The exit code from the CLI command execution</returns>
public async Task<int> StartCliCommand()
{
_toolCliProcess.Start();
#if NET5_0_OR_GREATER
await _toolCliProcess.WaitForExitAsync();
#else
await Task.Run(() => _toolCliProcess.WaitForExit()); // TODO
#endif
return _toolCliProcess.ExitCode;
}
}
Expand Down
Loading

0 comments on commit 5017db2

Please sign in to comment.