projectkudu / KuduSync

A file copying tool with semantic appropriate for deploying web site files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Satellite assemblies are not deployed with a web job

thedmi opened this issue · comments

commented

If a web job uses RESX files to translate strings, the web job fails because it cannot find the satellite assemblies containing the translated resources (e.g. a de folder containing MyLib.resources.dll.

The satellite assemblies must be copied, because they logically belong with the EXE that references an assembly with satellite assemblies.

See also this stackoverflow post.

I assume you are using a .NET web application with WebJobs, right?
When kudu deploys a .NET web application it first builds the project to a temporary directory and them copies (using KuduSync) from that directory to wwwroot.

Can you verify whether these resources files are actually getting built and bin placed to the temporary directory?

One way to do that is to open your project in visual studio and publish it to "file system" and see the files there.

Thanks,
Amit

commented

Yes it is a .NET web application. Both the web application and the webjob console application contain the satellite assemblies when I publish them from VS as you suggested. Also, the satellite assemblies are there on the azure webapp filesystem under site/wwwroot/bin.

Is there a switch that I need to pass to kudu sync to enable this? The kudu sync call was generated into the deployment script, and I haven't modified it since. The script was generated before we had a webjob, however.

Here is the sync call from the script:

:: 3. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
) 

The WebJob requires all its assemblies/dlls/binaries to be deployed to the same WebJob directory.
For example to: wwwroot\App_Data\jobs\continuous\myjob.
If the WebJob has a dependency on a files that is not in that directory then it will fail.
You need to make sure that during deployment all related files end up in that directory.

The issue here is not KuduSync related.
KuduSync will only copy (sync) files from source to destination, it has no other knowledge to copy for example the same files to 2 different locations/destinations.

In your case, the build process probably doesn't put the resources assemblies in the WebJob directory as required.

commented

You need to make sure that during deployment all related files end up in that directory.

I thought that's what Kudu Sync is here for in the first place. If I have to manually hack together a bunch of XCOPY commands, what do I need Kudu Sync for then?

.NET RESX files are the de-facto standard on .NET to localize applications. And RESX files create satellite assemblies, see this MSDN article for some in-depth information.

If not with RESX files, how would you implement web jobs that can handle multiple languages?

KuduSync is a fancy copy tool, its purpose is to sync between your repository (or build artifacts directory) to wwwroot.
By sync I mean it will only copy files that are new or changed and will remove files that were removed.

To go back to the actual issue, which I assume is that the WebJob directory doesn't contain the resource dlls?
If so, first you need to make sure that during the build process the resource dlls end up inside the webjob directory.

commented

I already had a workaround using the following XCOPY command:

xcopy   
   "%DEPLOYMENT_TARGET%\bin\*" 
   "%DEPLOYMENT_TARGET%\app_data\jobs\continuous\myjob\" 
   /Y /E

With this, the subfolders containing the satellite assemblies are copied (after Kudu Sync has run) and correctly loaded by my web job. The resulting web job directory then has e.g. de and fr subfolders, each containing a MyAssembly.resources.dll.

I can live with the XCOPY solution, but was just wondering whether Kudu Sync supports this, because I expected to not be the first one that tries to deploy a multi-language-capable web job. But apparently I am :-) .

Thanks anyway!

This has nothing to do with kudusync. Instead, it's likely a problem with what msbuild produces. Please see this article and try testing your deployment locally using those steps. You may find that those files are missing from the output directory.

commented

Ok, we're getting closer. The publish directory contains the satellite assemblies in the web application folder (bin). This is correct, because they are used in the web app as well. The publish directory also contains the web job under app_data\jobs\continuous\myjob. However, the satellite assemblies are missing there.

So if this is not a kudu sync issue, what is it then? Obviously it cannot be an MSBuild problem, because MSBuild wouldn't even know how to create a web job directory. There must be something that plugs into the publish mechanism to produce the web job folder, do you know what that is?

It actually is msbuild related. When you enable WebJobs, the project gets modified to publish the WebJobs alongside the site. That's why you see app_data\jobs\continuous\myjob containing those files. But there must be a bug that prevents it from copying satellite assemblies.

Are you sure you have the latest version of the WebJobs package?

Oh, it turns out that this issue already came up! See projectkudu/kudu#1503. Can you try the workaround that @bradygaster gives there?

Closing this one as it is not kudusync related. Feel free to comment on that other thread.