ASP.NET Core: Exclude or include files on publish

Related searches

There were before aspdotnet1.0 include/exclude sections on project.json file

{
  "exclude": [
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "**.xproj",
    "**.user",
    "**.vspscc"
  ]
}

Where is this section in ASP.NET Core 1.1 (there is no project.json)? Are there similar sections on .csproj file or .pubxml?

Visual Studio publish profiles (.pubxml) for ASP.NET Core app , Exclude files. When publishing ASP.NET Core web apps, the following assets are included: Build artifacts; Folders and files matching the� Unfortunately the voted answer did not work for me. I had an ASP.NET Core web project and I was using Web Deploy to a remote server. I was trying to exclude a whole folder under wwwroot from being included in the deployment and after various trials and different combinations of things the only thing that worked for me was a combination of both:

In .csproj for Visual Studio versions 15.3 and higher, this keeps the files visible in Visual Studio (whereas "Content Remove" does not), and prevents the files from being published.

<ItemGroup>
    <Content Update="appsettings*.json" CopyToPublishDirectory="Never" />
</ItemGroup>

Excluding Files and Folders from Deployment, This topic describes how you can exclude files and folders from a web NET Core . NET 4 - Enterprise Deployment Series 4 Advanced Topics; Excluding a web application with a realistic level of complexity, including an ASP. Package/Publish Web page lets you specify what you want to include in� I have an asp core 2.1 project, and I'm trying to publish via web deploy. I have a folder called "Angular" and inside that are my source files (including some .json files for angular's config) - these get built (via a separate process "ng build") into the wwwroot/app directory ready for publish.

After Visual Studio 2017 15.3

Edit the .csproj file to manually exclude files/folder from being published

<ItemGroup>
  <Content Remove="src\**" />
  <Content Remove="node_modules\**" />
</ItemGroup>

ref: https://www.danielcrabtree.com/blog/273/fixing-the-duplicate-content-error-after-upgrading-visual-studio-2017

Customize an ASP.NET project to control which files are included , Control which files are included when publishing an ASP. also how to exclude specific folders, when the project is published or deployed. Including / Excluding files from build with VS2017 and .NET Core I have a project where the wwwroot for an ASP.NET Core application is an SPA managed entirely by a node build chain. This means VS is completely hands-off with regards to the development of the UI, but it does have to somewhat be aware of it to debug and publish.

With Visual Studio 2017 (tested in 15.6.5), you can right-click on the file in the Solution Explorer and set the Build Action to None.

It will update your .csproj file like this:

<ItemGroup>
  <Content Remove="appsettings.Development.json" />
  <Content Remove="appsettings.json" />
  <Content Remove="npm-shrinkwrap.json" />
  <Content Remove="package.json" />
  <Content Remove="tsconfig.json" />
</ItemGroup>

<ItemGroup>
  <None Include="appsettings.Development.json" />
  <None Include="appsettings.json" />
  <None Include="npm-shrinkwrap.json" />
  <None Include="package.json" />
  <None Include="tsconfig.json" />
</ItemGroup>

Hope this helps.

How to exclude projects to publish when publishing from a solution , Is there a way to do within a solution file by configurin NET.Sdk.Publish. TransformFiles.targets(49,5): error MSB4018: The You may have better luck asking on StackOverflow or the Visual Studio Community or an ASP. I have the following folder structure for my .NET Core 2.1 project: How can I include folder AppData and all of its subfolders and files when I publish the solution? I tried adding this to .csproj file but it didn't work: <ItemGroup> <Folder Include="AppData\*" /> </ItemGroup> EDIT. I also tried with this and it didn't work:

I noticed that my folders with a few files in them were not being published- I tried right clicking the folders in the project to see if I could select an option to include the folder with the deployment- it's not there, but I did find if I select the files inside the folder and mark them to copy on deployment, it will copy the files and create their folder in the process.

This helps if your folder has files, but doesn't help if your folders are empty.

dotnet/AspNetCore.Docs, We are currently publishing to IIS via Web Deploy. stackoverflow.com/ questions/42712055/asp-net-core-exclude-or-include-files-on-publish. Exclude files. When publishing ASP.NET Core web apps, the following assets are included: Build artifacts; Folders and files matching the following globbing patterns: **\*.config (for example, web.config) **\*.json (for example, appsettings.json) wwwroot\** MSBuild supports globbing patterns.

.NET Core CLI; In the Create a new ASP.NET Core web application dialog: Select either the Web Application or the Web Application (Model-View-Controller) project template. Select the Enable Razor runtime compilation check box. Use the -rrc or --razor-runtime-compilation template option. For example, the following command creates a new Razor

Publishing your ASP.NET Core application There are lots of options for hosting your .NET Core application, especially now you can choose linux and take advantage of potentially cheaper hosting. Whatever you choose, a useful first step is figuring out how to package up your app so you can publish it to your chosen host.

Comments
  • MigratePublishOptionsRule link is dead.
  • This answer is for project before Visual Studio 2017 15.3. Please refer to @Wagner-Pereira for the latest projects
  • This is a much better solution than accepted answer! Note the Update attribute so that you can apply it to files which have been already included in project by default because they are under the root folder
  • I also agree. This also works in VS 2019, version 16.0.0 (just tested)
  • Works for me. Reference here: docs.microsoft.com/en-us/aspnet/core/host-and-deploy/…
  • Confirmed that this still works. Tried everything above and nothing worked, but this one did.
  • This is the solution that works now. CopyToPublishDirectory or CopyToOutputDirectory haven't worked at all after 15.3
  • This really helps me.
  • Yes, I know about csproj instead of project.json, but where is include/exclude secion?
  • Updated my answer.