{"id":18267371,"url":"https://github.com/spboyer/copydocfile-example","last_synced_at":"2025-09-09T02:32:35.414Z","repository":{"id":50065842,"uuid":"86459353","full_name":"spboyer/copydocfile-example","owner":"spboyer","description":"Example of ASP.NET Core copying Documentation file when `dotnet publish` called. This is not a built in feature since project.json conversion -\u003e csproj","archived":false,"fork":false,"pushed_at":"2021-06-05T05:02:12.000Z","size":7,"stargazers_count":9,"open_issues_count":8,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-01T06:50:34.065Z","etag":null,"topics":["aspnet-core","aspnetcore","msbuild","msbuild-files","msbuild-task","swagger"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spboyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-28T12:48:59.000Z","updated_at":"2022-10-20T13:49:33.000Z","dependencies_parsed_at":"2022-09-22T07:57:30.610Z","dependency_job_id":null,"html_url":"https://github.com/spboyer/copydocfile-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spboyer%2Fcopydocfile-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spboyer%2Fcopydocfile-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spboyer%2Fcopydocfile-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spboyer%2Fcopydocfile-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spboyer","download_url":"https://codeload.github.com/spboyer/copydocfile-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232382175,"owners_count":18514740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnet-core","aspnetcore","msbuild","msbuild-files","msbuild-task","swagger"],"created_at":"2024-11-05T11:27:03.866Z","updated_at":"2025-01-03T19:17:31.249Z","avatar_url":"https://github.com/spboyer.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## copydocfile-example\n\nSee GitHub [Issue #795](https://github.com/dotnet/sdk/issues/795) for the details and discussion.\n\nOne of the [undocumented changes](https://docs.microsoft.com/en-us/dotnet/articles/core/migration/) of converting from project.json to csproj, was the `\u003cDocumentationFile\u003e` no longer automatically copied to the output folder during the build or publish process.\n\nThere 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.\n\nAdd the following snippet to the .csproj to enable the copy of the documentation file to the output folder.\n\n```xml\n  \u003cTarget Name=\"PrepublishScript\" BeforeTargets=\"PrepareForPublish\"\u003e\n    \u003cItemGroup\u003e\n      \u003cDocFile Include=\"bin\\$(Configuration)\\$(TargetFramework)\\*.xml\" /\u003e\n    \u003c/ItemGroup\u003e\n    \u003cCopy SourceFiles=\"@(DocFile)\" DestinationFolder=\"$(PublishDir)\" SkipUnchangedFiles=\"false\" /\u003e\n  \u003c/Target\u003e\n\n\u003c!-- Added by Visual Studio, Visual Studio for Mac, or hand code in other IDE --\u003e\n  \u003cPropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \"\u003e\n    \u003cDocumentationFile\u003ebin\\Debug\\netcoreapp1.1\\copydocfile-example.xml\u003c/DocumentationFile\u003e\n  \u003c/PropertyGroup\u003e\n  \u003cPropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \"\u003e\n    \u003cDocumentationFile\u003ebin\\Release\\netcoreapp1.1\\copydocfile-example.xml\u003c/DocumentationFile\u003e\n  \u003c/PropertyGroup\u003e\n```\n\nIt supports the **F5** options as well as the `dotnet build` / `dotnet publish` CLI commands.\n\nAnother important option tested was the ability to pass a custom **output** folder using the `--o|--output` paramter.\n\n```console\ndotnet publish -c Release -o myreleasefolder\n```\n\n## Other options\n\nYou can also add additional output locations to the `\u003cDocumentationFile\u003e` node.\n\n```xml\n \u003cPropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \"\u003e\n    \u003cDocumentationFile\u003ebin\\Debug\\netcoreapp1.1\\copydocfile-example.xml\u003c/DocumentationFile\u003e\n    \u003c!-- creates the file in the root of the project --\u003e\n    \u003cDocumentationFile\u003ecopydocfile-example.xml\u003c/DocumentationFile\u003e\n    \u003c!-- Creates the file in a \"docs\" folder --\u003e\n    \u003cDocumentationFile\u003edocs\\copydocfile-example.xml\u003c/DocumentationFile\u003e\n  \u003c/PropertyGroup\u003e\n```\n\n---\n\n\u003e [tattoocoder.com](https://tattoocoder.com) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e GitHub [@spboyer](https://github.com/spboyer) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Twitter [@spboyer](https://twitter.com/spboyer)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspboyer%2Fcopydocfile-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspboyer%2Fcopydocfile-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspboyer%2Fcopydocfile-example/lists"}