Exemplo n.º 1
0
        private async Task <Envoy> ResolveComponentOnTargetAsync(string componentName, ITargetScopeService targetScope)
        {
            ITargetScopeService targetbuildBuildSpecScope = targetScope.GetDefaultBuildSpecScope();
            IEnumerable <Envoy> matchingComponents        = await targetbuildBuildSpecScope.TargetScope.ResolveAsync(new QualifiedName(componentName));

            if (matchingComponents.HasMoreThan(1))
            {
                throw new CommandLineOperationException("Multiple components matching the provided name were found. This likely indicates a corrupt project file.");
            }

            Envoy componentEnvoy = matchingComponents.SingleOrDefault();

            if (componentEnvoy == null)
            {
                CommandLineInterfaceApplication.WriteError(await CreateResolveComponentErrorMessageAsync(componentName, targetScope.GetScopeDisplayName(), targetScope));
            }

            return(componentEnvoy);
        }