@@ -55,6 +55,8 @@ public class ComputeWasmPublishAssets : Task
5555
5656 public bool FingerprintDotNetJs { get ; set ; }
5757
58+ public bool EnableThreads { get ; set ; }
59+
5860 public bool IsWebCilEnabled { get ; set ; }
5961
6062 [ Output ]
@@ -163,8 +165,10 @@ private List<ITaskItem> ProcessNativeAssets(
163165 var key = kvp . Key ;
164166 var asset = kvp . Value ;
165167 var isDotNetJs = IsDotNetJs ( key ) ;
168+ var isDotNetWorkerJs = IsDotNetWorkerJs ( key ) ;
166169 var isDotNetWasm = IsDotNetWasm ( key ) ;
167- if ( ! isDotNetJs && ! isDotNetWasm )
170+
171+ if ( ! isDotNetJs && ! isDotNetWasm && ! isDotNetWorkerJs )
168172 {
169173 if ( resolvedNativeAssetToPublish . TryGetValue ( Path . GetFileName ( asset . GetMetadata ( "OriginalItemSpec" ) ) , out var existing ) )
170174 {
@@ -197,11 +201,16 @@ private List<ITaskItem> ProcessNativeAssets(
197201 {
198202 var aotDotNetJs = WasmAotAssets . SingleOrDefault ( a => $ "{ a . GetMetadata ( "FileName" ) } { a . GetMetadata ( "Extension" ) } " == "dotnet.js" ) ;
199203 ITaskItem newDotNetJs = null ;
200- if ( aotDotNetJs != null && FingerprintDotNetJs )
204+ if ( aotDotNetJs != null )
201205 {
202206 newDotNetJs = new TaskItem ( Path . GetFullPath ( aotDotNetJs . ItemSpec ) , asset . CloneCustomMetadata ( ) ) ;
203207 newDotNetJs . SetMetadata ( "OriginalItemSpec" , aotDotNetJs . ItemSpec ) ;
204- newDotNetJs . SetMetadata ( "RelativePath" , $ "_framework/{ $ "dotnet.{ DotNetJsVersion } .{ FileHasher . GetFileHash ( aotDotNetJs . ItemSpec ) } .js"} ") ;
208+
209+ string relativePath = FingerprintDotNetJs
210+ ? $ "_framework/{ $ "dotnet.{ DotNetJsVersion } .{ FileHasher . GetFileHash ( aotDotNetJs . ItemSpec ) } .js"} "
211+ : "_framework/dotnet.js" ;
212+
213+ newDotNetJs . SetMetadata ( "RelativePath" , relativePath ) ;
205214
206215 updateMap . Add ( asset . ItemSpec , newDotNetJs ) ;
207216 Log . LogMessage ( MessageImportance . Low , "Replacing asset '{0}' with AoT version '{1}'" , asset . ItemSpec , newDotNetJs . ItemSpec ) ;
@@ -221,6 +230,35 @@ private List<ITaskItem> ProcessNativeAssets(
221230 continue ;
222231 }
223232
233+ if ( isDotNetWorkerJs )
234+ {
235+ var aotDotNetWorkerJs = WasmAotAssets . SingleOrDefault ( a => $ "{ a . GetMetadata ( "FileName" ) } { a . GetMetadata ( "Extension" ) } " == "dotnet.worker.js" ) ;
236+ ITaskItem newDotNetWorkerJs = null ;
237+ if ( aotDotNetWorkerJs != null )
238+ {
239+ newDotNetWorkerJs = new TaskItem ( Path . GetFullPath ( aotDotNetWorkerJs . ItemSpec ) , asset . CloneCustomMetadata ( ) ) ;
240+ newDotNetWorkerJs . SetMetadata ( "OriginalItemSpec" , aotDotNetWorkerJs . ItemSpec ) ;
241+ newDotNetWorkerJs . SetMetadata ( "RelativePath" , "_framework/dotnet.worker.js" ) ;
242+
243+ updateMap . Add ( asset . ItemSpec , newDotNetWorkerJs ) ;
244+ Log . LogMessage ( MessageImportance . High , "Replacing asset '{0}' with AoT version '{1}'" , asset . ItemSpec , newDotNetWorkerJs . ItemSpec ) ;
245+ }
246+ else
247+ {
248+ newDotNetWorkerJs = new TaskItem ( asset ) ;
249+ newDotNetWorkerJs . SetMetadata ( "RelativePath" , "_framework/dotnet.worker.js" ) ;
250+ Log . LogMessage ( MessageImportance . High , "Promoting asset '{0}' to Publish asset." , asset . ItemSpec ) ;
251+ }
252+
253+ ApplyPublishProperties ( newDotNetWorkerJs ) ;
254+ nativeStaticWebAssets . Add ( newDotNetWorkerJs ) ;
255+ if ( resolvedNativeAssetToPublish . TryGetValue ( "dotnet.worker.js" , out var resolved ) )
256+ {
257+ filesToRemove . Add ( resolved ) ;
258+ }
259+ continue ;
260+ }
261+
224262 if ( isDotNetWasm )
225263 {
226264 var aotDotNetWasm = WasmAotAssets . SingleOrDefault ( a => $ "{ a . GetMetadata ( "FileName" ) } { a . GetMetadata ( "Extension" ) } " == "dotnet.wasm" ) ;
@@ -262,6 +300,8 @@ static bool IsDotNetJs(string key)
262300 return fileName . StartsWith ( "dotnet." , StringComparison . Ordinal ) && fileName . EndsWith ( ".js" , StringComparison . Ordinal ) && ! fileName . Contains ( "worker" ) ;
263301 }
264302
303+ static bool IsDotNetWorkerJs ( string key ) => string . Equals ( "dotnet.worker.js" , Path . GetFileName ( key ) , StringComparison . Ordinal ) ;
304+
265305 static bool IsDotNetWasm ( string key ) => string . Equals ( "dotnet.wasm" , Path . GetFileName ( key ) , StringComparison . Ordinal ) ;
266306 }
267307
@@ -540,7 +580,7 @@ private void GroupResolvedFilesToPublish(
540580
541581 foreach ( var candidate in resolvedFilesToPublish )
542582 {
543- if ( AssetsComputingHelper . ShouldFilterCandidate ( candidate , TimeZoneSupport , InvariantGlobalization , CopySymbols , customIcuCandidateFilename , out var reason ) )
583+ if ( AssetsComputingHelper . ShouldFilterCandidate ( candidate , TimeZoneSupport , InvariantGlobalization , CopySymbols , customIcuCandidateFilename , EnableThreads , out var reason ) )
544584 {
545585 Log . LogMessage ( MessageImportance . Low , "Skipping asset '{0}' because '{1}'" , candidate . ItemSpec , reason ) ;
546586 if ( ! resolvedFilesToPublishToRemove . ContainsKey ( candidate . ItemSpec ) )
0 commit comments