-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created
.props
file to copy .env files to the publish directory (#138)
* Added `DotEnv.Core.Props` package to the example project
- Loading branch information
1 parent
3bd9806
commit dec1114
Showing
4 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<metadata> | ||
<id>DotEnv.Core.Props</id> | ||
<version>1.0.1</version> | ||
<authors>David Román Amariles</authors> | ||
<owners>David Román Amariles</owners> | ||
<projectUrl>https://github.com/MrDave1999/dotenv.core</projectUrl> | ||
<license type="expression">MIT</license> | ||
<readme>README.md</readme> | ||
<icon>dotenv-icon-nuget.png</icon> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description> | ||
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. | ||
</description> | ||
<releaseNotes> | ||
- fix: Added .props extension to the build/DotEnv.Core.Props file. | ||
</releaseNotes> | ||
<copyright>Copyright ©2023 David Román Amariles</copyright> | ||
<tags>properties props dotenv env environment variables</tags> | ||
</metadata> | ||
|
||
<files> | ||
<file src="README.md" target="" /> | ||
<file src="..\dotenv-icon-nuget.png" target="" /> | ||
<file src="build\**" target="build" /> | ||
</files> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<!-- | ||
Redefine the DefaultItemExcludes property to exclude the folders as ./bin, ./obj and .env files of samples. | ||
This also excludes sample .env files that are located in subdirectories of the project folder. | ||
--> | ||
<DefaultItemExcludes> | ||
$(DefaultItemExcludes); | ||
**\.env.example; | ||
**\example.env; | ||
**\.env.sample; | ||
**\sample.env; | ||
**\.env.template; | ||
**\template.env | ||
</DefaultItemExcludes> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- | ||
Copy all the .env files to the publish directory (except for sample files). It will also copy .env files that are in subdirectories. | ||
The publish directory contains the assemblies ready for deployment to a hosting system (for example, a server, PC, laptop) for execution. | ||
--> | ||
<Content | ||
Include="**\*.env*" | ||
CopyToPublishDirectory="PreserveNewest" | ||
Exclude="$(DefaultItemExcludes)" | ||
/> | ||
</ItemGroup> | ||
|
||
</Project> |