From dec1114e904d4ebc67a02e2261521eb6d332ed5b Mon Sep 17 00:00:00 2001 From: Dave Roman <43916038+MrDave1999@users.noreply.github.com> Date: Thu, 29 Jun 2023 21:06:18 -0500 Subject: [PATCH] Created `.props` file to copy .env files to the publish directory (#138) * Added `DotEnv.Core.Props` package to the example project --- example/DotEnv.Core.Example.csproj | 6 +++++- props/DotEnv.Core.nuspec | 29 +++++++++++++++++++++++++++ props/README.md | 26 ++++++++++++++++++++++++ props/build/DotEnv.Core.Props.props | 31 +++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 props/DotEnv.Core.nuspec create mode 100644 props/README.md create mode 100644 props/build/DotEnv.Core.Props.props diff --git a/example/DotEnv.Core.Example.csproj b/example/DotEnv.Core.Example.csproj index 9922bf3..1ff6291 100644 --- a/example/DotEnv.Core.Example.csproj +++ b/example/DotEnv.Core.Example.csproj @@ -1,4 +1,4 @@ - + Exe @@ -11,4 +11,8 @@ + + + + diff --git a/props/DotEnv.Core.nuspec b/props/DotEnv.Core.nuspec new file mode 100644 index 0000000..f26dcff --- /dev/null +++ b/props/DotEnv.Core.nuspec @@ -0,0 +1,29 @@ + + + + DotEnv.Core.Props + 1.0.1 + David Román Amariles + David Román Amariles + https://github.com/MrDave1999/dotenv.core + MIT + README.md + dotenv-icon-nuget.png + false + + dotenv.core.props is a file that represents a set of properties that will tell MSBuild to copy the .env files + from the project folder to the publish directory. + + + - fix: Added .props extension to the build/DotEnv.Core.Props file. + + Copyright ©2023 David Román Amariles + properties props dotenv env environment variables + + + + + + + + \ No newline at end of file diff --git a/props/README.md b/props/README.md new file mode 100644 index 0000000..3c07628 --- /dev/null +++ b/props/README.md @@ -0,0 +1,26 @@ +**DotEnv.Core.Props** is a file that represents a set of properties that will tell MSBuild to copy the .env files from the project folder to the publish directory. + +This .props file **excludes** the following sample .env files: +- `.env.example` +- `example.env` +- `.env.sample` +- `sample.env` +- `.env.template` +- `template.env` + +## Installation + +Run the following command from the terminal: +``` +dotnet add package DotEnv.Core.Props +``` + +## How to use it? + +The .props file does not need to be used directly, simply run the `dotnet publish` command and MSBuild will copy the .env files to the publish directory. + +Remember that .env files must follow either of these two conventions: +- `.env.{name}` (e.g., .env.config). +- `{name}.env` (e.g., config.env). + +Following these conventions is necessary for MSBuild to know which file to copy to the publish directory. \ No newline at end of file diff --git a/props/build/DotEnv.Core.Props.props b/props/build/DotEnv.Core.Props.props new file mode 100644 index 0000000..85b1feb --- /dev/null +++ b/props/build/DotEnv.Core.Props.props @@ -0,0 +1,31 @@ + + + + + + $(DefaultItemExcludes); + **\.env.example; + **\example.env; + **\.env.sample; + **\sample.env; + **\.env.template; + **\template.env + + + + + + + + + \ No newline at end of file