public async Task <InspectionValue> InspectPackageAsync(
            EnvironmentValue environment,
            InspectionKey key,
            Boolean restoreSDKPackage,
            IBuildEngine be,
            CancellationToken token
            )
        {
            const String PROCESS = "NuGetUtils.MSBuild.Exec.Inspect";

            return(await this._inspections.GetOrAdd(key, theKey => new UtilPack.AsyncLazy <InspectionValue>(async() =>
            {
                await be.LogProcessInvocationMessage(PROCESS);

                var startTime = DateTime.UtcNow;
                var env = await this.ProcessMonitor.CallProcessAndGetResultAsync <InspectConfiguration <String>, PackageInspectionResult>(
                    PROCESS,
                    new InspectConfiguration <String>()
                {
                    DisableLogging = true,
                    InspectFilePath = DefaultConfigurationConfiguration.STANDARD_INPUT_OUR_OUTPUT_MARKER,
                    NuGetConfigurationFile = key.SettingsLocation,
                    RestoreFramework = key.NuGetFramework,
                    RestoreRuntimeID = environment.ThisRuntimeID,
                    SDKFrameworkPackageID = environment.SDKPackageID,
                    SDKFrameworkPackageVersion = environment.SDKPackageVersion,
                    PackageID = key.PackageID,
                    PackageVersion = key.PackageVersion,
                    AssemblyPath = key.AssemblyPath,

                    ShutdownSemaphoreName = NuGetUtilsExecProcessMonitor.CreateNewShutdownSemaphoreName(),
                    // ReturnValuePath is not used by Inspect program
#if !NET46
                    RestoreSDKPackage = restoreSDKPackage
#endif
                },
                    token
                    );
                await be.LogProcessEndMessage(PROCESS, startTime);

                var result = env.GetFirstOrDefault();
                if (result == null)
                {
                    throw new Exception($"Errors occurred during package inspection: { env.GetSecondOrDefault() }.");
                }

                return new InspectionValue(result);
            })));
        }
Exemple #2
0
 internal TaskProxy(
     NuGetUtilsExecProcessMonitor processMonitor,
     InitializationArgs initializationArgs,
     EnvironmentValue environment,
     InspectionValue entrypoint,
     MethodInspectionInfo entrypointMethod,
     TypeGenerationResult generationResult
     )
 {
     this._processMonitor     = ArgumentValidator.ValidateNotNull(nameof(processMonitor), processMonitor);
     this._initializationArgs = ArgumentValidator.ValidateNotNull(nameof(initializationArgs), initializationArgs);
     this._environment        = ArgumentValidator.ValidateNotNull(nameof(environment), environment);
     this._entrypoint         = ArgumentValidator.ValidateNotNull(nameof(entrypoint), entrypoint);
     this._entrypointMethod   = ArgumentValidator.ValidateNotNull(nameof(entrypointMethod), entrypointMethod);
     this._propertyInfos      = generationResult
                                .Properties
                                .Select((p, idx) => (p, idx))
                                .ToImmutableDictionary(t => t.p.Name, t => new TaskPropertyHolder(generationResult.PropertyTypeNames[t.idx], t.p.Output, !Equals(t.p.PropertyType, typeof(String))));
     this._cancellationTokenSource = new CancellationTokenSource();
 }