Why does a LESS file have to be set as Build Actio

2019-06-20 02:22发布

问题:

I have an Azure website. I also have dotless running in my MVC app to translate and bundle Less files. When I deploy a release build to Azure, the Less file returns 404 unless I set it to Build Action="Content" in it's properties. Once I change that setting, everything works as expected.

So, I no longer have an issue, except I don't understand why it has to be set to Content. Can someone explain?

回答1:

Build Action="Content" tells the publishing process that this file should be copied as-is to the destination.

It's there so you don't bring along all your source files, readme files and other associated "developer fluff" when you're trying to publish the output of the build process. It's an opt-in process to make sure you don't bring anything sensitive by accident, like a private key.

Most item templates in Visual Studio set their Build Action to the right thing for you by default, generally so well that you don't even think about this until a template doesn't get this right and you wonder where your files are.