An open API service indexing awesome lists of open source software.

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

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)