0

So following this thread In Visual Studio, how can I set the Build Action for an entire folder? the solution works for me. I have a webpack configuration that creates hashed files in a Build folder that get published. The problem that I have now is that the files that are no longer generated are still available on live. Here's the scenario:

  • On every build the script removes everything from the ./Build folder
  • First time index.js and main.js are generated and are published using wildcard configuration in .csproj file
  • Second time ./Build folder is again cleaned and only index.js is generated however main.js is still available on live.

I guess it is a problem as beside .js and .css media files are bundled as well, images and fonts are loaded and hashed and in current state it will become quite crowded with a bunch of versions of the same files. Any idea how to solve this?

Community
  • 1
  • 1
  • I`m not sure your problem according to your description, could you please description it more detail? Besides,Is the main.js file not generated? Or the main.js file not generate but is still available? But why main.js file was not generated at second time build and how did you know the main.js file is available? Would you mind sharing us more detail information (steps, .csproj etc) about this issue so that we can reproduce this issue? Thanks. – Leo Liu Feb 28 '17 at 06:12
  • .csproj configuration for generated file inclusion is the one from the link there. I'm working on a multi-page app and each of them has a .js file let's call them index.js and main.js'. They are used as entry points for the webpack so when TFS get's to the NPM task to files are generated in a Build folder. They get to on live thanks to the wildcard configuration in .csproj(...Include="Build**."`). On live you open for ex: www.ss.com/Build/js/(index.js|main.js) the files are there. – Daniel Verejan Feb 28 '17 at 07:35
  • Let's say that you no longer have the page that requires main.js, it's no longer in the entry list of webpack configuration so when you run webpack it's no longer generated. In the ./Build/js folder you'll have only index.js. It goes on live and index.js is updated. main.js is not generated after TFS runs NPM task but it still remains available on live. If you'll open in browser a direct link to it, it will still be there. Hope I was clear with the explanation – Daniel Verejan Feb 28 '17 at 07:39
  • Seems that files that are no longer included in the project but were in the past just stay there in the release folder. – Daniel Verejan Feb 28 '17 at 08:04
  • Do you use VS build or TFS build? If you use Visual Studio build, could please try to use MSBuild command line? If you use TFS build, would you mind sharing us the build definition? Thanks. – Leo Liu Mar 01 '17 at 02:06

1 Answers1

0

Ok so the problem in my case was with the release configuration.

Using TFS as VCS. There I have Visual Studio Build with MSBuild x86 set in advanced configuration. MSBuild configuration has the wildcard to include all files and folders from ./Build folder, which it did.

Now to the problem - for deployments/release I again use a TFS configuration, there I have a task Azure App Service Deploy. This takes the packaged from build configuration and deploy it on server. In the Additional Deployment Options group there's the Remove Additional Files at Destination. Without it files that don't have any matches in the deployed package are not deleted.

Exemple 1 without Remove Additional Files at Destination option:

  • Deploy location has files: a.js, b.js, c.js
  • On TFS Build a new package is created with updated a.js, c.js and a new file z.js. Package does no longer contains the file b.js;
  • The package is deployed
  • After deploy, deploy location has files: a.js(updated), b.js, c.js(updated), z.js(new)

Exemple 2 with Remove Additional Files at Destination option:

  • Deploy location has files: a.js, b.js, c.js
  • On TFS Build a new package is created with updated a.js, c.js and a new file z.js. Package does no longer contains the file b.js;
  • The package is deployed
  • After deploy, deploy location has files: a.js(updated), c.js(updated), z.js(new), b.js file is removed from deploy location.