PersistRuntimeVersion() private method

private PersistRuntimeVersion ( IBuildManager buildManager, Version version ) : void
buildManager IBuildManager
version Version
return void
Exemplo n.º 1
0
        /// <summary>
        /// WebPages stores the version to be compiled against in AppSettings as &gt;add key="webpages:version" value="1.0" /&lt;.
        /// Changing values AppSettings does not cause recompilation therefore we could run into a state where we have files compiled against v1 but the application is
        /// currently v2.
        /// </summary>
        private static void InvalidateCompilationResultsIfVersionChanged(
            IBuildManager buildManager,
            IFileSystem fileSystem,
            string binDirectory,
            Version currentVersion
            )
        {
            Version previousVersion = WebPagesDeployment.GetPreviousRuntimeVersion(buildManager);

            // Persist the current version number in BuildManager's cached file
            WebPagesDeployment.PersistRuntimeVersion(buildManager, currentVersion);

            if (previousVersion == null)
            {
                // Do nothing.
            }
            else if (previousVersion != currentVersion)
            {
                // If the previous runtime version is different, perturb the bin directory so that it forces recompilation.
                WebPagesDeployment.ForceRecompile(fileSystem, binDirectory);
                var httpCompileException = new HttpCompileException(
                    ConfigurationResources.WebPagesVersionChanges
                    );
                // Indicator for tooling
                httpCompileException.Data[ToolingIndicatorKey] = true;
                throw httpCompileException;
            }
        }