Esempio n. 1
0
        public static LockFileTarget GetTargetAndThrowIfNotFound(this LockFile lockFile, string frameworkAlias, string runtimeIdentifier)
        {
            LockFileTarget lockFileTarget = lockFile.GetTargetAndReturnNullIfNotFound(frameworkAlias, runtimeIdentifier);

            if (lockFileTarget == null)
            {
                string frameworkString = frameworkAlias;
                string targetMoniker   = string.IsNullOrEmpty(runtimeIdentifier) ?
                                         frameworkString :
                                         $"{frameworkString}/{runtimeIdentifier}";

                string message;
                if (string.IsNullOrEmpty(runtimeIdentifier))
                {
                    message = string.Format(Strings.AssetsFileMissingTarget, lockFile.Path, targetMoniker, frameworkString);
                }
                else
                {
                    message = string.Format(Strings.AssetsFileMissingRuntimeIdentifier, lockFile.Path, targetMoniker, frameworkString, runtimeIdentifier);
                }

                throw new BuildErrorException(message);
            }

            return(lockFileTarget);
        }