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; //} }
/// <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\Xenko.Core.Packages\TargetGenerator.tt" foreach (var package in packages) { var packageVar = NugetStore.GetPackageVersionVariable(package.Id, packageVersionPrefix); var packageTarget = String.Format(@"{0}\Targets\{1}.targets", package.Path, package.Id); // Special case: if major version 1.0 still exists, use it as default (new projects should be created with props file) var defaultPackageVersion = store.GetLocalPackages(package.Id).Select(x => x.Version).FirstOrDefault(x => x.Version.Major == 1 && x.Version.Minor == 0) ?? package.Version; var defaultPackageVersionNormalized = defaultPackageVersion.ToNuGetVersion().ToNormalizedString(); #line default #line hidden this.Write(" <PropertyGroup>\r\n <"); #line 16 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(" Condition=\"\'$("); #line 16 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Override)\' != \'\'\">$("); #line 16 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Override)</"); #line 16 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(">\r\n <"); #line 17 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Saved>$("); #line 17 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(")</"); #line 17 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Saved>\r\n"); #line 18 "C:\DEV\xenko\sources\assets\Xenko.Core.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.GetLocalPackages(package.Id).Where(p => p.Version.Version.Major < 3).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.ToNuGetVersion().ToNormalizedString(); #line default #line hidden this.Write(" <"); #line 30 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Revision Condition=\"\'$("); #line 30 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(")\' == \'"); #line 30 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(majorVersion)); #line default #line hidden this.Write("."); #line 30 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(minor.Key)); #line default #line hidden this.Write("\'\">"); #line 30 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(latestPackageVersionNormalized)); #line default #line hidden this.Write("</"); #line 30 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Revision>\r\n"); #line 31 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" } } #line default #line hidden this.Write(" <"); #line 33 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(">$("); #line 33 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Revision)</"); #line 33 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(">\r\n <"); #line 34 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Invalid Condition=\"\'$("); #line 34 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(")\' == \'\' or !Exists(\'"); #line 34 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageTarget)); #line default #line hidden this.Write("\')\">true</"); #line 34 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Invalid>\r\n <"); #line 35 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(" Condition=\"\'$("); #line 35 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Invalid)\' == \'true\'\">"); #line 35 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(defaultPackageVersionNormalized)); #line default #line hidden this.Write("</"); #line 35 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(">\r\n </PropertyGroup>\r\n"); #line 37 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" } #line default #line hidden this.Write(" <Target Name=\"CheckPackages\">\r\n"); #line 39 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" foreach (var package in packages) { var packageVar = NugetStore.GetPackageVersionVariable(package.Id, packageVersionPrefix); #line default #line hidden this.Write(" <Message Condition=\"\'$("); #line 42 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Invalid)\' == \'true\'\" Text=\"Package "); #line 42 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(package.Id)); #line default #line hidden this.Write(" with version [$("); #line 42 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write("Saved)] not found. Use version $("); #line 42 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(") instead\" />\r\n"); #line 43 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" } #line default #line hidden this.Write(" </Target>\r\n"); #line 45 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" foreach (var package in packages) { var packageVar = NugetStore.GetPackageVersionVariable(package.Id, packageVersionPrefix); foreach (var packageVersion in store.GetLocalPackages(package.Id).Where(p => p.Version.Version.Major < 3)) { var packageTarget = String.Format(@"{0}\Targets\{1}.targets", packageVersion.Path, packageVersion.Id); #line default #line hidden this.Write(" <Import Project=\""); #line 51 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageTarget)); #line default #line hidden this.Write("\" Condition=\"Exists(\'"); #line 51 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageTarget)); #line default #line hidden this.Write("\') And \'$("); #line 51 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVar)); #line default #line hidden this.Write(")\' == \'"); #line 51 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(packageVersion.Version.ToNuGetVersion().ToNormalizedString())); #line default #line hidden this.Write("\'\" />\r\n"); #line 52 "C:\DEV\xenko\sources\assets\Xenko.Core.Packages\TargetGenerator.tt" } } #line default #line hidden this.Write("</Project>\r\n"); return(this.GenerationEnvironment.ToString()); }
internal TargetGenerator(NugetStore store, List <NugetLocalPackage> packages, string packageVersionPrefix) { this.store = store; this.packages = packages; this.packageVersionPrefix = packageVersionPrefix; }