dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.39k stars 10k forks source link

Blazor wasm hosted Project Integrity errors on Deployment to Azure App service #37861

Closed nssidhu closed 2 years ago

nssidhu commented 2 years ago

This is .NET 6 RC2 Blazor Hosted WebAssembly App and deploying it to Azure App service (windows) I am getting lots of integrity related errors .

I tired running locally in Release Mode and browsing it in Incognito mode without problem.

index.html:1 

       Failed to find a valid digest in the 'integrity' attribute for resource 'https://getinlinedev-staging.azurewebsites.net/_framework/Serilog.Enrichers.Environment.dll' with computed SHA-256 integrity 'Lbxblrss7XKRuEZFwDckN1swP9G9Qpa7WAHFILwpw8c='. The resource has been blocked.

some more errors

Uncaught (in promise) TypeError: Failed to fetch
    at lt.loadResourceWithoutCaching (blazor.webassembly.js:1)
    at lt.loadResourceWithCaching (blazor.webassembly.js:1)
index.html:1 

       Failed to find a valid digest in the 'integrity' attribute for resource 'https://getinlinedev-staging.azurewebsites.net/_framework/dotnet.timezones.blat' with computed SHA-256 integrity 'IRA3aSR05YjbbkfXMY8trRnmm9TfDlmrKiB4EPRl16I='. The resource has been blocked.

Failed to find a valid digest in the 'integrity' attribute for resource 'https://getinlinedev-staging.azurewebsites.net/_framework/dotnet.wasm' with computed SHA-256 integrity '1Qbl2oLjBqIKta0l6OQZQH03S0ZS/S9M18GsKlAnhuQ='. The resource has been blocked.
index.html:1 

       Unknown error occurred while trying to verify integrity.
service-worker.js:37 

       Uncaught (in promise) TypeError: Failed to fetch
    at service-worker.js:37
    at async onInstall (service-worker.js:37)

this is how my service-wroker.published.js looks

// Caution! Be sure you understand the caveats before publishing an application with
// offline support. See https://aka.ms/blazor-offline-considerations

self.importScripts('./service-worker-assets.js');
self.addEventListener('install', event => event.waitUntil(onInstall(event)));
self.addEventListener('activate', event => event.waitUntil(onActivate(event)));
self.addEventListener('fetch', event => event.respondWith(onFetch(event)));

const cacheNamePrefix = 'offline-cache-';
const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`;
const offlineAssetsInclude = [ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ];
const offlineAssetsExclude = [ /^service-worker\.js$/ ];

const notifyNewVersion = () => {
    const bc = new BroadcastChannel('blazor-channel');

    bc.postMessage('new-version-found');

    bc.onmessage = function (message) {
        if (message && message.data == "skip-waiting") {
            console.info("Calling skipWaiting");
            self.skipWaiting();
            bc.postMessage("reload-page");
        }
    }
}

async function onInstall(event) {
    console.info('Service worker: Install');

    // Fetch and cache all matching items from the assets manifest
    const assetsRequests = self.assetsManifest.assets
        .filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url)))
        .filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url)))
       // .map(asset => new Request(asset.url, { integrity: asset.hash }));
        .map(asset => new Request(asset.url, { integrity: asset.hash, cache: 'no-cache' }));
    await caches.open(cacheName).then(cache => cache.addAll(assetsRequests));
}

async function onActivate(event) {
    console.info('Service worker: Activate');

    // Delete unused caches
    const cacheKeys = await caches.keys();
    await Promise.all(cacheKeys
        .filter(key => key.startsWith(cacheNamePrefix) && key !== cacheName)
        .map(key => caches.delete(key)));
}

async function onFetch(event) {
    let cachedResponse = null;
    if (event.request.method === 'GET') {
        // For all navigation requests, try to serve index.html from cache
        // If you need some URLs to be server-rendered, edit the following check to exclude those URLs
        const shouldServeIndexHtml = event.request.mode === 'navigate';

        const request = shouldServeIndexHtml ? 'index.html' : event.request;
        const cache = await caches.open(cacheName);
        cachedResponse = await cache.match(request);
    }

    return cachedResponse || fetch(event.request);
}
nssidhu commented 2 years ago

Even after commenting PWA related code, I am still getting the same error, i guess error is not related to service-worker or PWA. I excluded service-worker file in index.html

javiercn commented 2 years ago

@nssidhu thanks for contacting us.

You can look at https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-5.0#resolve-integrity-check-failures-1 to get an idea on how to troubleshoot this issue.

One thing to check would be to see if you can run the published app locally without issues.

nssidhu commented 2 years ago

secondly from the link that you provided, only the section(Disable integrity checking for PWAs) will apply which I tried still no luck.

https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-5.0#disable-integrity-checking-for-pwas-1

I tried to disable integrity check, that did not help .map(asset => new Request(asset.url)); I also tried by commenting the code that downloads the service worker(think this would totally remove PWA feature) in index.html of client side project. This did not help either


  <!--
    <script>navigator.serviceWorker.register('service-worker.js');</script>
    -->

Additionally i tried deploying the project to brand new Azure App Service (windows), same error there too.

I am running into problems with PowerShell script, will update with result from that once i have it executed.

image

nssidhu commented 2 years ago

Looks like i might have found the problem. Running it locally indicates the following files with 404 not found. How do i remove them or how do i find out which package installed them ?

image

javiercn commented 2 years ago

Those two files are related to localization/internationalization.

Can you show what your csproj file looks like?

nssidhu commented 2 years ago

Here is Server Project. I did comment out package related to that and tried republishing but still ran into the above error.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>

  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="PredicateBuilder.cs" />
  </ItemGroup>

<ItemGroup>
  <!--<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />-->
  <!--<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.6" />
  <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.6" />-->
</ItemGroup>  

  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.18.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.18.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.SnapshotCollector" Version="1.4.2" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.0-rc.1.21452.15" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.18.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0-rc.1.21452.15" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0-rc.1.21452.15" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.0-rc.1.21452.15" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0-rc.1.21452.15" />

    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.7.21378.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="6.0.0-preview.7.21378.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-preview.7.21378.4">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="6.2.12-preview.4.21253.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0-preview.7.21378.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-preview.7.21378.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="6.0.0-preview.7.21378.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-preview.7.21378.4">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
    <PackageReference Include="Microsoft.Identity.Client" Version="4.36.0" />
    <PackageReference Include="Microsoft.Owin.Security.OAuth" Version="4.2.0" />
    <PackageReference Include="QRCoder" Version="1.4.1" />
    <PackageReference Include="SendGrid" Version="9.24.2" />

    <PackageReference Include="Serilog.AspNetCore" Version="4.1.1-dev-00229" />
    <PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" />
    <PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
    <PackageReference Include="Serilog.Expressions" Version="3.2.1-dev-00071" />
    <PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.1.0" />
    <PackageReference Include="Serilog.Sinks.MSSqlServer" Version="5.6.0" />
    <PackageReference Include="SerilogTimings" Version="2.3.1-dev-00010" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.1" />
    <PackageReference Include="Twilio.AspNet.Core" Version="5.37.2" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Client\GetInLineV6New.Client.csproj" />
    <ProjectReference Include="..\Shared\GetInLineV6New.Shared.csproj" />
  </ItemGroup>

</Project>
nssidhu commented 2 years ago

Also publishing to azure app service give me altogether different Integrity errors.

image

javiercn commented 2 years ago

@nssidhu we would need to see the csproj for the wasm project.

nssidhu commented 2 years ago

Here is the Client (WASM) one.

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <!--<InvariantGlobalization>true</InvariantGlobalization>-->
    <!--<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>-->
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="wwwroot\js\QrCodeReader\**" />
    <Compile Remove="wwwroot\js\SpeechSDK-JavaScript-1.18.0\**" />
    <Content Remove="wwwroot\js\QrCodeReader\**" />
    <Content Remove="wwwroot\js\SpeechSDK-JavaScript-1.18.0\**" />
    <EmbeddedResource Remove="wwwroot\js\QrCodeReader\**" />
    <EmbeddedResource Remove="wwwroot\js\SpeechSDK-JavaScript-1.18.0\**" />
    <None Remove="wwwroot\js\QrCodeReader\**" />
    <None Remove="wwwroot\js\SpeechSDK-JavaScript-1.18.0\**" />
  </ItemGroup>

  <ItemGroup>
    <Compile Remove="Pages\Org\ManageOrgCategories.razor.cs" />
  </ItemGroup>

  <ItemGroup>
    <Content Remove="Pages\Org\ManageOrgCategories.razor" />
    <Content Remove="wwwroot\js\azureSpeech.js" />
    <Content Remove="wwwroot\js\require.js" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="BlazorApplicationInsights" Version="1.3.0" />
    <PackageReference Include="BlazorBarcodeScanner.ZXing.JS" Version="0.2.4" />
    <PackageReference Include="Delegate.SassBuilder" Version="1.4.0" />
    <PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="6.0.0-rc.1.21452.15" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-rc.1.21452.15" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-rc.1.21452.15" PrivateAssets="all" />
    <PackageReference Include="Blazored.LocalStorage" Version="4.1.5" />
    <PackageReference Include="Blazored.Modal" Version="6.0.1" />
    <PackageReference Include="Blazored.Toast" Version="3.2.2" />
    <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.0-rc.1.21452.15" />
     <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0-rc.1.21451.13" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0-rc.1.21451.13" />
    <PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="3.0.2-dev-10289" />
    <PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.1.0" />
    <PackageReference Include="Serilog.Sinks.BrowserConsole" Version="1.0.0" />
    <PackageReference Include="Serilog.Sinks.BrowserHttp" Version="1.0.0-dev-00021" />
    <PackageReference Include="SerilogTimings" Version="2.3.1-dev-00010" />
    <PackageReference Include="Syncfusion.Blazor.BarcodeGenerator" Version="19.3.0.47" />
    <PackageReference Include="Syncfusion.Blazor.Inputs" Version="19.3.0.47" />
    <PackageReference Include="Syncfusion.Blazor.Navigations" Version="19.3.0.47" />
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
    <PackageReference Include="Toolbelt.Blazor.SpeechSynthesis" Version="9.0.0" />

  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Shared\GetInLineV6New.Shared.csproj" />
  </ItemGroup>

  <ItemGroup>
    <ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
  </ItemGroup>

  <ItemGroup>
    <Content Update="wwwroot\beep-04.mp3">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\favicon.ico">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\google1af0197d4d7bf819.html">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\icon-192.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\icon-512.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\barcode_scanner.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\android-icon-192x192.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-114x114.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-120x120.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-144x144.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-152x152.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-180x180.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-57x57.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-60x60.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-72x72.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\apple-icon-76x76.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\circle-cropped1.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\favicon-16x16.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\favicon-256x256.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\favicon-32x32.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\favicon-96x96.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\favicon.ico">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\instructions.txt">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\ms-icon-144x144.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\ms-icon-150x150.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\ms-icon-310x310.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\favicon\ms-icon-70x70.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\images\Line.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\js\app.js">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\QrCodes\09-27-2921\QrCode_RG-1.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\manifest.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\pristine-609.mp3">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\PrivacyPolicy.html">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Update="wwwroot\TermsAndCondition.html">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <None Update="Shared\DisplayActiveTokens.razor.css">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>
nssidhu commented 2 years ago

Any idea why would I get different integrity error for the same Code ? and how to go about fixing this ?

nssidhu commented 2 years ago

I got it working with combination of cleanup. 1) Manually deleted bin & Obj folder in all the projects in my Blazor hosted solution. This alone did not help. 2) Also had to Manually delete the files from azure App Service using Kudo a) delete the site folder b) Delete cache folder from OS disk ( i had done stop and start as well as restart many times but did not help) when Publishing my project I already had "Remove Additional Files" Option checked but that was not helping either.

I strongly suggest improvements in the following 1) Visual studio Clean command should do its intended work and delete all files under bin & obj plus any cached files. 2) Publish command should have option to clear everything on Azure App Service so that it is like as if you have created new app service environment or there should be such option on the portal.

99% of the problems are due to App service instance amassing all the junk during multiple deployments. There should be a way or option to clean that instance like new. I accidently figured that when creating and deploying it to staging environment where my deployed code started working.

There should be an option to clean environment because lots of configurations are already done for environment like setting up certificate, domain, KeyVault access managed certificate etc.

javiercn commented 2 years ago

@nssidhu thanks for the additional details.

This is in fact very useful information, since it points out that the issue is related to App Service. Do you know how you were able to get in this state?

For my understanding, what exactly do you mean when you refer to Delete cache folder from OS disk

@danroth27 who can we loop in here to help? It's not clear to me right now how could we even reproduce this issue.

nssidhu commented 2 years ago

Since I am in development mode I happens to try out various libraries some libraries gave me error which I later uninstalled including internationalization ones.

I ended up deploying multiple times(8-10) over a period of time (2-3 months) with all these libraries added or removed etc.

I did not keep track of all the places I deleted it from but do remember one place(""site root"). So not sure which delete helped.

image

image

In the end I feel it was polluted App service environment. I say feel because I am not sure which clean up step helped, but I am sure that the app started working after the cleanup. I mentioned combination of cleanup where 1st part was clearing my local environment(deleting bin/Obj) etc. I feel the Clean command is lacking somewhere and not clearing everything that we expect of it.

JasonFreeberg commented 2 years ago

Hey @nssidhu , I'm on App Service. Wanted to confirm a couple things:

nssidhu commented 2 years ago

Visual Studio 2022 Version 17.0.0 Preview 6.0. Deploying to Azure App Service Windows, as Web App

nssidhu commented 2 years ago

I have again run into the integrity error. This time, the only thing I did was, I upgraded from .NET RC2 to .NET 6 version.

image

Here is how i am publishing from Visual Studio 2022. The publish had been working fine, it just broke after upgrading to .NET 6 image

In case someone want to inspect or have a look, I will keep everything intact for a day, before I start to manually clean the App service environment.

nssidhu commented 2 years ago

some interesting findings

I incorrectly assumed that something is wrong on the Azure App Service environment.

It turns out that manually deleting the obj & bin folders for the projects helps.

This is what i tried 1) Published my project to local folder and tried to run that from the published folder. This gave me exact error that i would get if published on Azure app Service. this itself proves that issue is not related to Azure App Service Environment.

2) I manually deleted the published local folder to prepare for new publish. second i also deleted all bin & obj folders from my project. I again published to local folder and tried to run the app from local folder. This time i was able to run it without any problem.

3) I Published the project to Azure App Service.(I had checked "Remove Additional files at destination" I was able to browse the website without any kind of integrity errors.

Hope this helps save day for someone who might run into this problem.

So it turns out that Clean & rebuild in Visual Studio 2022 is not able to remove some of the cached files.

nssidhu commented 2 years ago

@javiercn Can this issue be posted/reported to Visual Studio team so that they can enable the deleting of bin & obj folders and regenerating on publish? NOTE: They do have clean option but that itself does not help, may the clean might have some bugs and does not work as expected.

javiercn commented 2 years ago

@nssidhu thanks for contacting us.

Rebuild is just a combination of Clean + Build so if there's a clean option, that should work.

What seems to be happening, from what I understand, is that you are running into issues when publishing more than once? (Even after cleaning in between).

Does this happen when you publish, delete the publish directory and publish again?

nssidhu commented 2 years ago

Agree, but looks like Clean or Rebuild both does not work as intended. Yes I did delete the publish directory before republishing, when run it produces the same error.

The only way out is manually deleting the bin & obj folder from file explorer and than doing the builds or directly publish(which builds it anyway).

I recently upgraded the project to .NET 6 LTS, which resulted into integrity error. So rather than multiple cycles of publish(which I thought earlier might have contributed to this), looks like it occurs when some major package changes are done to the project. I my recent issue I just updated my project to .NET 6 LTS once only and integrity errors started showing up.

javiercn commented 2 years ago

@nssidhu thanks for the additional details.

Does the issue disappear once you've updated the project and cleaned the bin and obj folders? (Meaning that after the upgrade and removing the folders, the sequence publish, delete publish folder, publish) works again?

nssidhu commented 2 years ago

Yes

Sent from Yahoo Mail for iPhone

On Friday, November 12, 2021, 9:00 AM, Javier Calvarro Nelson @.***> wrote:

@nssidhu thanks for the additional details.

Does the issue disappear once you've updated the project and cleaned the bin and obj folders? (Meaning that after the upgrade and removing the folders, the sequence publish, delete publish folder, publish) works again?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

javiercn commented 2 years ago

@nssidhu thanks for the additional details.

Seems then that the issue only happens when updating a project between 5.0 and 6.0.

nssidhu commented 2 years ago

That was the most recent one, it does happens when there are major package changes. I remember another instance when I added some globalization package I ran into integrity issue there too. I have tagged you on that issue but for different issue.

Sent from Yahoo Mail for iPhone

On Friday, November 12, 2021, 10:05 AM, Javier Calvarro Nelson @.***> wrote:

@nssidhu thanks for the additional details.

Seems then that the issue only happens when updating a project between 5.0 and 6.0.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

javiercn commented 2 years ago

@nssidhu thanks for the additional details.

Our current guidance is to clean up the project artifacts when making major upgrades as the complexity of getting the upgrade to work in a non clean environment is very high.

WayneHiller commented 2 years ago

I had the same issue if the app was copied to any other machine I would get errors. On my machine it would run fine from the Publish folder. I did not change the dotnet 6 version (Release). Deleting the bin + obj folders fixed it.

Interestingly I verified the dll version and dates reported in the errors were exactly the same as my publish folder. If I checked the Hash of one on my machine it was the same as listed in the service worker assents file. However if I checked the Hash on the other machine it was different. Same issue deploying to Ubuntu in a Docker container.