Beispiel #1
0
        public ProgressReport(NugetStore store, NugetPackage package)
        {
            if (store == null)
            {
                throw new ArgumentNullException(nameof(store));
            }
            this.store = store;
            version    = package.Version.ToSemanticVersion().ToNormalizedString();

            foreach (var progressProvider in store.SourceRepository.Repositories.OfType <IProgressProvider>())
            {
                progressProvider.ProgressAvailable += OnProgressAvailable;
            }
        }
 internal TargetGenerator(NugetStore store, List <NugetPackage> packages)
 {
     this.store    = store;
     this.packages = packages;
 }
Beispiel #3
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"14.0\" xmlns=\"http:" +
                       "//schemas.microsoft.com/developer/msbuild/2003\" InitialTargets=\"CheckPackages\">\r" +
                       "\n");

            #line 6 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
            foreach (var package in packages)
            {
                if (package.Tags != null && package.Tags.Contains("internal"))
                {
                    continue; // We don't want to polute the Common.targets file with internal packages
                }

                var packageVar    = NugetStore.GetPackageVersionVariable(package.Id);
                var packageTarget = String.Format(@"$(MSBuildThisFileDirectory)..\{0}\{1}.{2}\Targets\{1}.targets", store.RepositoryPath, package.Id, "$(" + packageVar + ")");

                // Special case: if major version 1.0 still exists, use it as default (new projects should be created with props file)
                var defaultPackageVersion           = store.FindLocalPackagesById(package.Id).Select(x => x.Version).FirstOrDefault(x => x.Version.Major == 1 && x.Version.Minor == 0) ?? package.Version;
                var defaultPackageVersionNormalized = defaultPackageVersion.ToSemanticVersion().ToNormalizedString();


            #line default
            #line hidden
                this.Write("  <PropertyGroup>\r\n    <");

            #line 21 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(" Condition=\"\'$(");

            #line 21 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Override)\' != \'\'\">$(");

            #line 21 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Override)</");

            #line 21 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(">\r\n    <");

            #line 22 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Saved>$(");

            #line 22 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(")</");

            #line 22 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Saved>\r\n");

            #line 23 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                // List all the correspondances: Major.minor -> latest installed explicit version

                // Get all the related versions of the same package also installed, and order by Major.Minor
                var allMajorVersions = store.FindLocalPackagesById(package.Id).GroupBy(p => p.Version.Version.Major, p => p);
                foreach (var major in allMajorVersions)
                {
                    var majorVersion = major.Key;
                    var minorPkg     = major.GroupBy(p => p.Version.Version.Minor, p => p);
                    foreach (var minor in minorPkg)
                    {
                        var latestPackage = minor.First();
                        var latestPackageVersionNormalized = latestPackage.Version.ToSemanticVersion().ToNormalizedString();

            #line default
            #line hidden
                        this.Write("    <");

            #line 35 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                        this.Write("Revision Condition=\"\'$(");

            #line 35 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                        this.Write(")\' == \'");

            #line 35 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(majorVersion));

            #line default
            #line hidden
                        this.Write(".");

            #line 35 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(minor.Key));

            #line default
            #line hidden
                        this.Write("\'\">");

            #line 35 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(latestPackageVersionNormalized));

            #line default
            #line hidden
                        this.Write("</");

            #line 35 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                        this.Write("Revision>\r\n");

            #line 36 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                    }
                }

            #line default
            #line hidden
                this.Write("    <");

            #line 38 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(">$(");

            #line 38 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Revision)</");

            #line 38 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(">\r\n    <");

            #line 39 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Invalid Condition=\"\'$(");

            #line 39 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(")\' == \'\' or !Exists(\'");

            #line 39 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageTarget));

            #line default
            #line hidden
                this.Write("\')\">true</");

            #line 39 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Invalid>\r\n    <");

            #line 40 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(" Condition=\"\'$(");

            #line 40 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Invalid)\' == \'true\'\">");

            #line 40 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(defaultPackageVersionNormalized));

            #line default
            #line hidden
                this.Write("</");

            #line 40 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(">\r\n  </PropertyGroup>\r\n");

            #line 42 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
            }

            #line default
            #line hidden
            this.Write("  <Target Name=\"CheckPackages\">\r\n");

            #line 44 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
            foreach (var package in packages)
            {
                var packageVar = NugetStore.GetPackageVersionVariable(package.Id);

            #line default
            #line hidden
                this.Write("    <Message Condition=\"\'$(");

            #line 47 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Invalid)\' == \'true\'\" Text=\"Package ");

            #line 47 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(package.Id));

            #line default
            #line hidden
                this.Write(" with version [$(");

            #line 47 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write("Saved)] not found. Use version $(");

            #line 47 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageVar));

            #line default
            #line hidden
                this.Write(") instead\" />\r\n");

            #line 48 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
            }

            #line default
            #line hidden
            this.Write("  </Target>\r\n");

            #line 50 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
            foreach (var package in packages)
            {
                var packageVar    = NugetStore.GetPackageVersionVariable(package.Id);
                var packageTarget = String.Format(@"$(MSBuildThisFileDirectory)..\{0}\{1}.{2}\Targets\{1}.targets", store.RepositoryPath, package.Id, "$(" + packageVar + ")");

            #line default
            #line hidden
                this.Write("  <Import Project=\"");

            #line 54 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageTarget));

            #line default
            #line hidden
                this.Write("\" Condition=\"Exists(\'");

            #line 54 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(packageTarget));

            #line default
            #line hidden
                this.Write("\')\" />\r\n");

            #line 55 "C:\DEV\xenko\sources\assets\SiliconStudio.Packages\TargetGenerator.tt"
            }

            #line default
            #line hidden
            this.Write("</Project>");
            return(this.GenerationEnvironment.ToString());
        }