BundlerMinifier icon indicating copy to clipboard operation
BundlerMinifier copied to clipboard

Does not run on Build solution

Open wolojoli opened this issue 11 months ago • 2 comments

Installed product versions

  • Visual Studio: 2022 Professional (17.9.4)
  • This extension: 2.9.9

Description

When enabling "Enabling bundle on build" the Nuget Package is added to the project, but the build does not trigger the bundle process.

Steps to recreate

  1. Create a new .Net 4.8 solution
  2. Add two javascript files
  3. Select them in the solution explorer and let them bundle
  4. Enable "Enabling bundle on build" by right clicking the buncleconfig.json file.
  5. Delete the bundle output files.
  6. Build the solution

Current behavior

There is no bundle.js file and no minified file.

Expected behavior

A newly generated bundle.js and bundle.min.js file.

wolojoli avatar Mar 21 '24 10:03 wolojoli

I just stumbled across this issue myself. It looks like "Enable bundle on build" added the appropriate NuGet package but didn't change csproj to actually do the bundling. I was able to get it working by adding the same stuff that the WebCompiler adds when you enable the compile on build functionality there.

First, inside of the EnsureNuGetPackageBuildImports target: <Error Condition="!Exists('..\packages\BuildBundlerMinifier2022.2.9.9\build\BuildBundlerMinifier.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\BuildBundlerMinifier2022.2.9.9\build\BuildBundlerMinifier.targets'))" />

And then just below that alongside a few other imports: <Import Project="..\packages\BuildBundlerMinifier2022.2.9.9\build\BuildBundlerMinifier.targets" Condition="Exists('..\packages\BuildBundlerMinifier2022.2.9.9\build\BuildBundlerMinifier.targets')" />

I didn't see any errors in Visual Studio to indicate why these lines didn't get added.

jsgraham avatar Jun 26 '24 15:06 jsgraham

~~Interesting. I'm currently get an exception trying to find the bundle NuGet..~~

I'm seeing the same thing, now that I properly re-added nuget.org to package sources in the VS NuGet Package Manager Options page. (using PackageReference for so long now I've forgotten how to use packages.config)

bakerhillpins avatar Jun 27 '24 20:06 bakerhillpins

@failwyn I've submitted a PR for this as well as one that enables dotnet tool support in the package.

Hopefully you'll have time to review and could get merged/published so I could make use of this in our processes in the near term.

bakerhillpins avatar Jul 24 '24 18:07 bakerhillpins

Hello, just curious if this has been published... I seem to still be having this issue in my Visual Studio.

ComtelJeremy avatar Jul 31 '24 21:07 ComtelJeremy

We’re testing it in my company and will publish Friday if all looks good; I can upload a debug version here if you want to help test before I publish it; the only issue with the debug version is that you won’t be able to use Minify On Build since I haven’t published the new NuGet package yet.

failwyn avatar Jul 31 '24 21:07 failwyn