Publishoptions recursively creates cshtml files

I have an ASP.NET Core application. In project.jsonI have a publish option configured as below

"publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "appsettings.development.json",
      "appsettings.staging.json",
      "appsettings.production.json",
      "web.config"
    ]
  },

I am using the default project template created vs 2015 for asp.net core web projects. Thus, all files .cshtmlare in the folder Views.

when i execute the command dotnet publish -c Developmentdotnet publishes Views to

C: \ MySolutionDir \ Src \ MyUIProjectDir \ Bin \ Development \ netcoreapp1.0 \ publish \ Views

then I will repeat the same command. This time cshtml files already exist in bin\Development\netcoreapp1.0\publish\Views, so this time the publish command additionally creates the following folder structure

C: \ MySolutionDir \ Src \ MyUIProjectDir \ Bin \ Development \ netcoreapp1.0 \ publish \ Bin \ Development \ netcoreapp1.0 \ publish \ Views

,

C:\MySolutionDir\Src\MyUIProjectDir\Bin\\netcoreapp1.0\\Bin\Development\netcoreapp1.0\\Bin\\netcoreapp1.0\\Views

.cshtml "MyUIProjectDir" "".

,

 C:\MySolutionDir\Src\MyUIProjectDir\bin\Staging
 C:\MySolutionDir\Src\MyUIProjectDir\bin\Production

publish cshtml "Staging" "Production" .

, publish cshtml "MyUIProjectDir\Views" ( bin).

+4
3

**/* wwwroot. 2 :

  • **/ *.cshtml .cshtml .cshtml (Views ):

    "publishOptions": {
       "include": [
          "wwwroot",
          "Views",
          ...
       ]
    }
    
  • .cshtml, wwwroot. exclude publishOptions:

    "publishOptions": {
      "exclude": [
          "wwwroot/*.cshtml"
      ]
    
+3

, Views, ** , wwwroot.

.cshtml, , ** , .

"publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "appsettings.development.json",
      "appsettings.staging.json",
      "appsettings.production.json",
      "web.config"
    ]
  },
+2

, , - bin obj.

"publishOptions": {
"include": [
  "wwwroot",
  "Views",
  "appsettings.json",
  "web.config"
],
"exclude": [
  "bin",
  "obj"
]  }

I also had to delete the entire contents of the AppData \ Local \ temp \ PublishTemp folder before publishing. For some reason, he still used the old settings until I deleted everything from the PublishTemp folder.

0
source

Source: https://habr.com/ru/post/1658129/


All Articles