https://github.com/spboyer/copydocfile-example
Example of ASP.NET Core copying Documentation file when `dotnet publish` called. This is not a built in feature since project.json conversion -> csproj
https://github.com/spboyer/copydocfile-example
aspnet-core aspnetcore msbuild msbuild-files msbuild-task swagger
Last synced: 4 months ago
JSON representation
Example of ASP.NET Core copying Documentation file when `dotnet publish` called. This is not a built in feature since project.json conversion -> csproj
- Host: GitHub
- URL: https://github.com/spboyer/copydocfile-example
- Owner: spboyer
- Created: 2017-03-28T12:48:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-06-05T05:02:12.000Z (almost 4 years ago)
- Last Synced: 2025-01-01T06:50:34.065Z (4 months ago)
- Topics: aspnet-core, aspnetcore, msbuild, msbuild-files, msbuild-task, swagger
- Language: C#
- Size: 6.84 KB
- Stars: 9
- Watchers: 5
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## copydocfile-example
See GitHub [Issue #795](https://github.com/dotnet/sdk/issues/795) for the details and discussion.
One of the [undocumented changes](https://docs.microsoft.com/en-us/dotnet/articles/core/migration/) of converting from project.json to csproj, was the `` no longer automatically copied to the output folder during the build or publish process.
There have been multiple solutions, both `pre` and `post` publish scripts. However, understanding how MSBUILD works and finding the simplest way is key. Thanks to [Eric Erhardt](https://github.com/eerhardt)'s [latest comment here](https://github.com/dotnet/sdk/issues/795#issuecomment-289782712) I think that this is the cleanest way.
Add the following snippet to the .csproj to enable the copy of the documentation file to the output folder.
```xml
bin\Debug\netcoreapp1.1\copydocfile-example.xml
bin\Release\netcoreapp1.1\copydocfile-example.xml
```It supports the **F5** options as well as the `dotnet build` / `dotnet publish` CLI commands.
Another important option tested was the ability to pass a custom **output** folder using the `--o|--output` paramter.
```console
dotnet publish -c Release -o myreleasefolder
```## Other options
You can also add additional output locations to the `` node.
```xml
bin\Debug\netcoreapp1.1\copydocfile-example.xml
copydocfile-example.xml
docs\copydocfile-example.xml
```---
> [tattoocoder.com](https://tattoocoder.com) ·
> GitHub [@spboyer](https://github.com/spboyer) ·
> Twitter [@spboyer](https://twitter.com/spboyer)