Я следил за Настройка Webpack в веб-формах ASP.NET Сесила Филлипа, чтобы ознакомиться с утилитой Webpack. Я прошел большую часть этого пути, но у меня возникли проблемы с разделом ближе к концу (Регистрация в ScriptManager).
Я добавил ScriptResourceDefinition с Path и DebugPath, установленными для минифицированной и неминифицированной версий вывода Webpack соответственно. Когда я загружаю страницу в сборке отладки, я получаю ожидаемый скрипт DebugPath. Однако, когда я загружаю его в сборке Release, а не в ожидаемом скрипте Path, я снова получаю DebugPath. Любая идея, почему это так, и как я могу получить правильный Path?





Обнаружил это. Оказывается, я сделал несколько ложных предположений о том, как работает ScriptManager. Вот ход моих мыслей -
Исследовано ScriptResourceDefinition.DebugPath:
Gets or sets the debug mode path of the script resource that is used when debug mode is enabled.
Просмотрел ссылку «См. Также» на Обзор отладки и трассировки приложений ASP.NET AJAX, указанную внизу:
When you deploy a release version of an WebForms application that uses Microsoft Ajax, set the application to release mode. This makes sure that ASP.NET uses the performance-optimized release version of the Microsoft Ajax libraries. If you have created debug and release versions of your custom script files and script resources, ASP.NET also uses the release versions. To set the application to release mode, do the following:
In the Web.config file, if the compilation element contains a debug attribute, make sure that the debug attribute is set to false.
Make sure that any Web page that contains a ScriptManager control has its ScriptMode property set to Release.
Посмотрел дальше в ScriptManager.ScriptMode:
The ScriptMode property specifies whether the ScriptManager control should render debug or release versions of client script libraries. This value can be superseded by values that are set in the configuration file and in the page directive.
...
[By default] Debug versions of client script libraries are used in the Web page when the retail attribute of the deployment configuration element is set to false. Otherwise, the release versions of client script libraries are used.
Чтобы проверить это, я попытался установить ScriptMode на Release, и он загрузил правильный файл.