在ASP.NET Core 1.1上我试图使用BundlerMinifier捆绑和缩小CSS和JS,所以我在.csproj上添加了以下任务(我不再使用project.json了):
<Target Name="BeforePublish">
<Exec Command="bower install" />
<Exec Command="dotnet bundle" />
</Target>
当我键入dotnet run
时,项目会运行,但即使我在csproj上有这些任务,也不会创建包。
注意:我在命令行中输入了dotnet bundle
,并且创建了捆绑包,这不是问题......
这是完整的csproj文件:
<Project ToolsVersion="15.0">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Web" Version="1.0.0-alpha-20161104-2-112">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Design" Version="1.1.0-preview4-final " />
<PackageReference Include="Microsoft.AspNetCore.Razor.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.2-beta1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.306" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.1.0-preview4-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.1.0-preview4-final" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="BeforePublish">
<Exec Command="bower install" />
<Exec Command="dotnet bundle" />
</Target>
</Project>
我错过了什么?
答案 0 :(得分:4)
这些是设置:
操作系统:Windows 10。
IDE :Visual Studio代码。
.NET核心版:1.1。
我担心你没有安装 BuildBundlerMinifier 包。因此,为了能够在运行 dotnet build 命令后运行捆绑,您必须按照以下步骤操作:
您可以在https://github.com/pmargom/CarRentalMVC1.1看到整个项目。
希望它有所帮助!!