public static string GetAddinSourcePath(this SourceInfo source, BuildContext ctx, SourceTagInfo stag) { SourcePuller sp = VersionControl.GetSourcePuller(source.Type); return(sp.GetSourceTagPath(ctx, source.Id, stag.Id)); }
void BuildSource(BuildContext ctx, SourceInfo source, SourceTagInfo stag, string logFile) { SourcePuller sp = VersionControl.GetSourcePuller(source.Type); sp.PrepareForBuild(ctx, source.Id, stag); string destPath = Path.GetFullPath(source.GetAddinSourcePath(ctx, stag)); string sourcePath = destPath; if (!string.IsNullOrEmpty(source.Directory)) { sourcePath = Path.Combine(sourcePath, NormalizePath(source.Directory)); } sourcePath = Path.GetFullPath(sourcePath); if (sourcePath != destPath && !sourcePath.StartsWith(destPath)) { throw new Exception("Invalid source directory: " + source.Directory); } string projectFile = sourcePath; if (!File.Exists(projectFile) && !projectFile.EndsWith(".xml")) { projectFile = Path.Combine(sourcePath, "addin-project.xml"); } else { sourcePath = Path.GetDirectoryName(projectFile); } if (!File.Exists(projectFile)) { string msg = "addin-project.xml file not found"; if (!string.IsNullOrEmpty(source.Directory)) { msg += " (looked in '" + source.Directory + "')"; } throw new Exception(msg); } AddinProject addinProject; StreamReader sr = new StreamReader(projectFile); using (sr) { XmlSerializer ser = new XmlSerializer(typeof(AddinProject)); addinProject = (AddinProject)ser.Deserialize(sr); } if (string.IsNullOrEmpty(addinProject.AppVersion)) { throw new Exception("Target application version not specified in addin-project.xml"); } AppReleaseInfo rel = ctx.Server.GetAppReleases(ctx.AppId).Where(r => r.AppVersion == addinProject.AppVersion).FirstOrDefault(); if (rel == null) { throw new Exception("Application release " + addinProject.AppVersion + " not found."); } RefreshAppRelease(ctx, rel); // Delete old packages foreach (string f in Directory.GetFiles(sourcePath, "*.mpack")) { File.Delete(f); } List <AddinData> addins = new List <AddinData> (); foreach (AddinProjectAddin addin in addinProject.Addins) { addins.Add(BuildProjectAddin(ctx, stag, logFile, sourcePath, rel, addin)); } ctx.Server.SetSourceTagBuildData(ctx.AppId, stag.Id, addins.ToArray()); }