static-import
1.1.0
dotnet tool install --global static-import --version 1.1.0
dotnet new tool-manifest
dotnet tool install --local static-import --version 1.1.0
#tool dotnet:?package=static-import&version=1.1.0
nuke :add-package static-import --version 1.1.0
<sup>🇯🇵 日本語</sup>
static-import
is a dotnet cli tool to migrate file(s) from another project, github or public website.
In addition, there are features to modify C# script on migration. See C# Script Options for more details.
Installation
On the command line, enter the following command to install package as a command.
.NET SDK 8.0+ is required
dotnet tool install -g SatorImaging.DotnetTool.StaticImport
dnx
Support
With .NET SDK 10.0 preview 6 or later, it can be run with dnx
command like as follows, without installation.
dnx static-import --yes -- <OPTIONS>
Basic Usage
Here shows how to migrate files to current folder.
static-import -o "." -i \
"local-file.cs" \
"github:user@repo/BRANCH_TAG_OR_COMMIT/path/to/file.cs" \
"https://gist.githubusercontent.com/..." \ # use raw url to download from gist
"https://inter.net/path/to/file.cs"
Type
static-import --help
for more options.
For the use in GitHub Actions, see .github/workflows/tests.yml for details.
In GitHub actions, actions/checkout
or git pull
won't restore commit date for downloaded files so that -f/--force-overwrite
option is required to migrate files from other repos.
GitHub Options
static-import
has dedicated scheme for GitHub files.
In contrast to https:
, it retrieves correct Last-Modified
value from repository.
github:<USER_NAME>@<REPO_NAME>/<REF>/path/to/file.ext
- REF: branch name, tag or commit hash
If the environment variable GH_TOKEN
or GITHUB_TOKEN
is defined, it is used for accesss to GitHub.
Here shows how to setup the variable in .yml
file.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
C# Script Options
There are options to modify C# script on copying. (original file doesn't change)
--internal
- make declared type visibility to
internal
. - NOTE: doesn't affect on nested types.
- make declared type visibility to
--namespace <NAME>
- change namespace.
- if name ending with
.
, it will be prepended (ex.Foo.
-->Foo.Original.Namespace
)
- if name ending with
- NOTE: nested namespace syntaxes leave untouched.
- change namespace.
namespace FileScoped; // 👈 changed
namespace Foo.Bar.Baz // 👈 changed
{
namespace Quuuuux // untouched
{
public class MyClass // 👈 changed
{
// untouched
public enum MyEnum { }
public struct MyStruct { }
public record MyRecord { }
public interface IMyInterface { }
}
}
}
License
MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
Version | Downloads | Last Updated |
---|---|---|
1.1.0 | 118 | 7/16/2025 |
1.1.0-rc.2 | 112 | 7/16/2025 |