Edit websitestrings in litium /

If you use multiple different build configurations you may need to change the csproj-file for the project and also the ExtensionsModuleRouterInitTask to build and include the compiled js-file as a resource.

The csproj-file is the section

  <ItemGroup>
    <EmbeddedResource Include="dist\Accelerator.js" Condition="'$(Configuration)' == 'Release' OR $(DefineConstants.Contains('BUILD_PACKAGE'))" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="dist\Accelerator.js.map" Condition="'$(Configuration)' == 'Release' OR $(DefineConstants.Contains('BUILD_PACKAGE'))" />
  </ItemGroup>

in this snippet we can see that the we include the embedded resource if the configuration is release or the definition constant BUILD_PACKAGE is set.

If we check the ExtensionsModuleRouterInitTask it looks like the following

        public void Init(IEnumerable<Assembly> assemblies)
        {
#if DEBUG && !BUILD_PACKAGE
            PackageManager.Register("~/Litium/Client/Scripts/dist", new DirectoryInfo($"{HostingEnvironment.MapPath("~/")}../{GetType().Assembly.GetName().Name}/dist").FullName);
#else
            PackageManager.Register("~/Litium/Client/Scripts", GetType().Assembly);
#endif
        }

where we can see that we using the embedded resource if we not building in DEBUG-mode and not have the BUILD_PACKAGE definition constant set.

So if you have more build configuration that you need to get the embedded resources included you can set the BUILD_PACKAGE definition constant in them.

The reason that we not included the generated JavaScript file when building in DEBUG is to allow the developer easy make changes in the JavaScript (TypeScript) source and get that changes included in the UI directly without needing to compile and restart the application.

I can see in the conditions from the csproj and the cs-file that the logic not is exactly the same but will correct that in next release.

If you want to do the changes by yourself it will be something like the following that will include the embedded files in all builds except the debug. Changes for the csproj, remeber to replace the nodes that already exists.

  <PropertyGroup Condition="'$(BuildPackage)' == 'true' Or '$(BuildUIPackage)' == 'true' Or '$(Configuration)' != 'Debug'">
    <DefineConstants>$(DefineConstants);BUILD_PACKAGE</DefineConstants>
  </PropertyGroup>
  <ItemGroup>
    <EmbeddedResource Include="dist\Accelerator.js" Condition="$(DefineConstants.Contains('BUILD_PACKAGE'))" />
    <EmbeddedResource Include="dist\Accelerator.js.map" Condition="$(DefineConstants.Contains('BUILD_PACKAGE'))" />
  </ItemGroup>

and the ExtensionsModuleRouterInitTask

#if BUILD_PACKAGE
            PackageManager.Register("~/Litium/Client/Scripts", GetType().Assembly);
#else
            PackageManager.Register("~/Litium/Client/Scripts/dist", new DirectoryInfo($"{HostingEnvironment.MapPath("~/")}../{GetType().Assembly.GetName().Name}/dist").FullName);
#endif

With this changes you may still have problem if you deploy a debug-build with webdeploy without explicit setting the BUILD_PACKAGE definition constant for debug builds.

1 Like