Skip to content

Unable to build project using VS 17.14 “DiscoverPrecompressedAssets” task failed unexpectedly #49180

Open
@javiercn

Description

@javiercn

The issue is caused by a bug in the caching logic that we use.

The issue has been fixed in #48952 and a fix will be available in 9.0.301

Adding the following snippets should workaround the issue

<Target Name="RemoveCachedDuplicates" AfterTargets="ResolveProjectStaticWebAssets">
  <ItemGroup>
    <_UniqueAssets Include="@(StaticWebAsset->Distinct())" />
    <StaticWebAsset Remove="@(_UniqueAssets)" />
    <StaticWebAsset Include="@(_UniqueAssets)" />
  </ItemGroup>
</Target>
<Target Name="_CleanupStaticWebAssetsCache" AfterTargets="Build">
  <PropertyGroup>
    <StaticWebAssetsCachePaths>
      $(_ResolveBuildCompressedStaticWebAssetsCachePath);
      $(_ResolveJsInitializerModuleStaticWebAssetsCachePath);
      $(_ResolveJSModuleStaticWebAssetsRazorCachePath);
      $(_ResolveJSModuleStaticWebAssetsCshtmlCachePath);
      $(_ResolveProjectStaticWebAssetsCachePath)
    </StaticWebAssetsCachePaths>
  </PropertyGroup>

  <ItemGroup>
    <_CacheFilesToDelete Include="$(StaticWebAssetsCachePaths)" />
  </ItemGroup>

  <Delete Files="@(_CacheFilesToDelete)" Condition="Exists('%(_CacheFilesToDelete.Identity)')" />
</Target>

Alternatively, the SDK version can be pinned to a working version using a global.json file

{
  "sdk": {
    "version": "9.0.204",
    "rollForward": "latestPatch"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions