/// <summary>
 ///
 /// </summary>
 /// <param name="guidIndex"></param>
 /// <param name="csProject"></param>
 /// <param name="reference"></param>
 private static void UpdateReference(
     Dictionary <Guid, CsProject> guidIndex,
     CsProject csProject,
     Reference reference)
 {
     if (guidIndex.ContainsKey(reference.ReferencedProjectGuid))
     {
         reference.CsProject = guidIndex[reference.ReferencedProjectGuid];
     }
     else
     {
         string msg =
             "Couldn't find project " + reference.Name +
             " that are referenced in project " + csProject.ProjectName;
         log.Error(msg);
     }
 }
Пример #2
0
        private static void CreateProjectTarget(XmlWriter w, CsProject project)
        {
            w.WriteStartElement("Target");
            w.WriteAttributeString("Name", DeMsbuildString(project.FullAbsoluteFileName));
            StringBuilder dependsOn = new StringBuilder();

            List <Reference> .Enumerator enumerator = project.References.GetEnumerator();

            bool first = true;

            while (enumerator.MoveNext())
            {
                if (enumerator.Current.CsProject != null)
                {
                    //this is a reference to a project that we have found the .csproj file to
                    //so we could include it in the build script

                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        dependsOn.Append(";");
                    }

                    dependsOn.Append(DeMsbuildString(enumerator.Current.CsProject.FullAbsoluteFileName));
                }
            }
            if (dependsOn.Length > 0)
            {
                w.WriteAttributeString("DependsOnTargets", dependsOn.ToString());
            }

            w.WriteStartElement("MSBuild");
            w.WriteAttributeString("Projects", project.FullAbsoluteFileName);
            //w.WriteAttributeString("StopOnFirstFailure","true" );
            w.WriteAttributeString("Targets", "build");
            w.WriteAttributeString("Properties", "Configuration=$(Configuration);Platform=$(Platform)");
            w.WriteEndElement(); //</MsBuild>
            w.WriteEndElement(); //</Target>
            w.Flush();
        }
Пример #3
0
        public static CsProject ReadProject(string fullAbsoluteFileName)
        {
            try
            {
                var project = new CsProject(fullAbsoluteFileName);
                var doc     = new XmlDocument();
                using (var reader = new XmlTextReader(fullAbsoluteFileName))
                {
                    doc.Load(reader);
                }

                project.Guid         = ExtractGuid(doc);
                project.AssemblyName = ExtractAssemblyName(doc);
                project.ProjectType  = ExtractProjectType(doc);
                project.OutputDebug  = ExtractOutputPathHelper(
                    ExtractOutputDirDebug(doc, project.AbsolutProjectDir),
                    project.AssemblyName,
                    Path.GetDirectoryName(project.FullAbsoluteFileName),
                    project.ProjectType);

                project.OutputRelease = ExtractOutputPathHelper(
                    ExtractOutputDirRelease(doc, project.AbsolutProjectDir),
                    project.AssemblyName,
                    Path.GetDirectoryName(project.FullAbsoluteFileName),
                    project.ProjectType);

                project.References.AddRange(ExtractDllReferences(doc, project.AbsolutProjectDir));
                project.References.AddRange(ExtractProjectReferences(doc));

                //if (project.OutputDebug != project.OutputRelease)
                //{
                //    log.Warning("The debug output and release output are not equal.");
                //}
                return(project);
            }
            catch (Exception e)
            {
                throw new Exception("Unable to read project " + fullAbsoluteFileName + " due to: " + e.Message.ToString(), e);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="staticDlls">all ready build dll that has no projectfile </param>
 /// <param name="dllPathIndex">a dictionary with dll debugbuild path at key</param>
 /// <param name="csProject">the project that we are trying to resolve references for</param>
 /// <param name="reference">the current reference</param>
 private static void UpdateReference(
     List <string> staticDlls,
     Dictionary <string, CsProject> dllPathIndex,
     CsProject csProject,
     Reference reference)
 {
     if (dllPathIndex.ContainsKey(reference.AbsolutDllPath))
     {
         reference.CsProject = dllPathIndex[reference.AbsolutDllPath];
     }
     else if (staticDlls.Contains(reference.AbsolutDllPath))
     {
         //Don't know if I have to do anything here. Maybe mark in in the project
         reference.IsPreCompiled = true;
     }
     else
     {
         string msg =
             "Couldn't find the referenced dll:" + reference.AbsolutDllPath +
             " that are referenced in project " + csProject.FullAbsoluteFileName +
             " or a project that builds this dll.";
         log.Error(msg);
     }
 }