net8" /> net8" /> net8"/>

Why are static assets included with nuget package in the project.assets.json file but actually not in the project?

52 Views Asked by At

I use this code in my Client1.csproj that I want to package:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> 
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>    
    <ImplicitUsings>enable</ImplicitUsings>
    <AssemblyVersion>1.0.0.8794</AssemblyVersion>    
    <StaticWebAssetBasePath>Client1</StaticWebAssetBasePath>   
     <IsPackable>true</IsPackable>
     <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
     <NoBuild>true</NoBuild>
     <IncludeBuildOutput>false</IncludeBuildOutput>
     <NuspecFile>$(SolutionDir)\Client1\Client1.nuspec</NuspecFile>   
  </PropertyGroup>

and this is my nuspec file:

<?xml version="1.0"?>
  <package  xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
    <metadata>
      <id>Client1</id>
      <version>1.2.53</version>    
      <title>Client1</title>
      <description>Desc</description>
      <authors>mz</authors>
      <owners>me</owners>    
      <requireLicenseAcceptance>false</requireLicenseAcceptance>    
      <releaseNotes>notes</releaseNotes>
      <copyright></copyright>
      <tags></tags>
      <dependencies>
        <dependency id="Microsoft.AspNetCore.Components.Web" version="8.0.0" />
        <dependency id="NuGet.Build.Tasks.Pack" version="6.8.0" />
        <dependency id="Microsoft.AspNetCore.Components.WebAssembly" version="8.0.0" />
        <dependency id="Microsoft.AspNetCore.Components.WebAssembly.DevServer" version="8.0.0" />
        <dependency id="MudBlazor" version="6.12.0" />    
      </dependencies>
      <summary></summary>
      <contentFiles>      
        <files include="wwwroot/css/*.css" buildAction="Content" copyToOutput="true" flatten="true" />
      </contentFiles>
    </metadata>
    <files>    
      <file src="wwwroot\css\*.css" target="content\css" />  
      <file src="bin\Release\net8.0\Client1.dll" target="lib\net8.0" />            
    </files>
  </package>

and this is part of project.assets.json file when I install package on the target project:

    "libraries": {
      "Client1/1.2.53": {
        "sha512": "kYwkGQ4Ea5/UXFy8yi15FanZ5dv1n5FV8mj7SXxo5fID+0VAoHLMQ1ig+ePOWYXWJqLCYAxylBaz9KjgPCubXw==",
        "type": "package",
        "path": "client1/1.2.53",
        "files": [
          ".nupkg.metadata",
          "client1.1.2.53.nupkg.sha512",
          "client1.nuspec",
          "content/css/app.css",
          "lib/net8.0/Client1.dll"
        ]
      },

but with these the https://localhost:nnnn/content/css/app.css has a 404 error. How to solve this?

0

There are 0 best solutions below