~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        [ProjectModelDataItem ("AbstractDotNetProject")]
52
52
        public abstract class DotNetProject : Project, IAssemblyProject
53
53
        {
54
 
 
55
54
                bool usePartialTypes = true;
56
55
                ProjectParameters languageParameters;
57
56
 
194
193
                        get { return projectReferences; }
195
194
                }
196
195
 
 
196
                public virtual bool CanReferenceProject (DotNetProject targetProject, out string reason)
 
197
                {
 
198
                        if (!TargetFramework.CanReferenceAssembliesTargetingFramework (targetProject.TargetFramework)) {
 
199
                                reason = GettextCatalog.GetString ("Incompatible target framework: {0}", targetProject.TargetFramework.Id);
 
200
                                return false;
 
201
                        }
 
202
 
 
203
                        reason = null;
 
204
 
 
205
                        return true;
 
206
                }
 
207
 
197
208
                public IDotNetLanguageBinding LanguageBinding {
198
209
                        get {
199
210
                                if (languageBinding == null) {
470
481
                        // Generated satellite resource files
471
482
                        
472
483
                        FilePath outputDir = conf.OutputDirectory;
473
 
                        string satelliteAsmName = Path.GetFileNameWithoutExtension (conf.OutputAssembly) + ".resources.dll";
 
484
                        string satelliteAsmName = Path.GetFileNameWithoutExtension (conf.CompiledOutputName) + ".resources.dll";
474
485
                        
475
486
                        HashSet<string> cultures = new HashSet<string> ();
476
487
                        foreach (ProjectFile finfo in Files) {
532
543
                                        if (p == null) {
533
544
                                                LoggingService.LogWarning ("Project '{0}' referenced from '{1}' could not be found", projectReference.Reference, this.Name);
534
545
                                                continue;
535
 
                                        }
536
 
 
537
 
                                        string refOutput = p.GetOutputFileName (configuration);
538
 
                                        if (string.IsNullOrEmpty (refOutput)) {
539
 
                                                LoggingService.LogWarning ("Project '{0}' referenced from '{1}' has an empty output filename", p.Name, this.Name);
540
 
                                                continue;
541
 
                                        }
542
 
 
543
 
                                        list.Add (refOutput);
544
 
 
 
546
                                        }
 
547
                                        DotNetProjectConfiguration conf = p.GetConfiguration (configuration) as DotNetProjectConfiguration;
545
548
                                        //VS COMPAT: recursively copy references's "local copy" files
546
 
                                        //but only copy the "copy to output" files from the immediate references
547
 
                                        if (processedProjects.Add (p))
548
 
                                                foreach (var f in p.GetSupportFileList (configuration))
549
 
                                                        list.Add (f.Src, f.CopyOnlyIfNewer, f.Target);
550
 
 
551
 
                                        DotNetProjectConfiguration refConfig = p.GetConfiguration (configuration) as DotNetProjectConfiguration;
552
 
 
553
 
                                        if (refConfig != null && refConfig.DebugMode) {
554
 
                                                string mdbFile = TargetRuntime.GetAssemblyDebugInfoFile (refOutput);
555
 
                                                if (File.Exists (mdbFile)) {
556
 
                                                        list.Add (mdbFile);
557
 
                                                }
 
549
                                        //but only copy the "copy to output" files from the immediate references
 
550
                                        if (processedProjects.Add (p) || supportReferDistance == 1) {
 
551
                                                foreach (var v in p.GetOutputFiles (configuration))
 
552
                                                        list.Add (v, true, v.CanonicalPath.ToString ().Substring (conf.OutputDirectory.CanonicalPath.ToString ().Length + 1));
 
553
 
 
554
                                                foreach (var v in p.GetSupportFileList (configuration))
 
555
                                                        list.Add (v.Src, v.CopyOnlyIfNewer, v.Target);
558
556
                                        }
559
557
                                }
560
558
                                else if (projectReference.ReferenceType == ReferenceType.Assembly) {
649
647
                        }
650
648
                        
651
649
                        yield return fileName;
652
 
                        Mono.Cecil.AssemblyDefinition adef;
653
 
                        try {
654
 
                                adef = Mono.Cecil.AssemblyDefinition.ReadAssembly (fileName);
655
 
                        } catch {
656
 
                                yield break;
657
 
                        }
658
 
                        foreach (Mono.Cecil.AssemblyNameReference aref in adef.MainModule.AssemblyReferences) {
659
 
                                string asmFile = Path.Combine (Path.GetDirectoryName (fileName), aref.Name);
 
650
 
 
651
                        foreach (var reference in SystemAssemblyService.GetAssemblyReferences (fileName)) {
 
652
                                string asmFile = Path.Combine (Path.GetDirectoryName (fileName), reference);
660
653
                                foreach (string refa in GetAssemblyRefsRec (asmFile, visited))
661
654
                                        yield return refa;
662
655
                        }
676
669
 
677
670
                public override IEnumerable<SolutionItem> GetReferencedItems (ConfigurationSelector configuration)
678
671
                {
679
 
                        List<SolutionItem> items = new List<SolutionItem> ();
 
672
                        List<SolutionItem> items = new List<SolutionItem> (base.GetReferencedItems (configuration));
680
673
                        if (ParentSolution == null)
681
674
                                return items;
682
675
 
817
810
                                        break;
818
811
                                }
819
812
                        }
820
 
                        
 
813
 
 
814
                        var config = (DotNetProjectConfiguration) GetConfiguration (configuration);
821
815
                        return Files.Any (file => file.BuildAction == BuildAction.EmbeddedResource
822
816
                                        && String.Compare (Path.GetExtension (file.FilePath), ".resx", StringComparison.OrdinalIgnoreCase) == 0
823
 
                                        && MD1DotNetProjectHandler.IsResgenRequired (file.FilePath));
 
817
                                        && MD1DotNetProjectHandler.IsResgenRequired (file.FilePath, config.IntermediateOutputDirectory.Combine (file.ResourceId)));
824
818
                }
825
819
                
826
820
                protected internal override DateTime OnGetLastBuildTime (ConfigurationSelector configuration)
850
844
                                return null;
851
845
                        //return all projects in the sln in case some are loaded dynamically
852
846
                        //FIXME: should we do this for the whole workspace?
853
 
                        return ParentSolution.GetAllProjects ().OfType<DotNetProject> ()
 
847
                        return ParentSolution.RootFolder.GetAllBuildableEntries (configuration).OfType<DotNetProject> ()
854
848
                                .Select (d => (string) d.GetOutputFileName (configuration))
855
849
                                .Where (d => !string.IsNullOrEmpty (d)).ToList ();
856
850
                }
872
866
                        if (config == null)
873
867
                                return false;
874
868
                        ExecutionCommand cmd = CreateExecutionCommand (configuration, config);
 
869
                        if (context.ExecutionTarget != null)
 
870
                                cmd.Target = context.ExecutionTarget;
875
871
 
876
872
                        return (compileTarget == CompileTarget.Exe || compileTarget == CompileTarget.WinExe) && context.ExecutionHandler.CanExecute (cmd);
877
873
                }
1060
1056
                        if (oldHandler.GetType () != newHandler.GetType ()) {
1061
1057
                                // If the file format has a default resource handler different from the one
1062
1058
                                // choosen for this project, then all resource ids must be converted
1063
 
                                foreach (ProjectFile file in Files) {
 
1059
                                foreach (ProjectFile file in Files.Where (f => f.BuildAction == BuildAction.EmbeddedResource)) {
1064
1060
                                        if (file.Subtype == Subtype.Directory)
1065
1061
                                                continue;
1066
1062
                                        string oldId = file.GetResourceId (oldHandler);
1149
1145
                        try {
1150
1146
                                try {
1151
1147
                                        ExecutionCommand executionCommand = CreateExecutionCommand (configuration, dotNetProjectConfig);
 
1148
                                        if (context.ExecutionTarget != null)
 
1149
                                                executionCommand.Target = context.ExecutionTarget;
1152
1150
 
1153
1151
                                        if (!context.ExecutionHandler.CanExecute (executionCommand)) {
1154
1152
                                                monitor.ReportError (GettextCatalog.GetString ("Can not execute \"{0}\". The selected execution mode is not supported for .NET projects.", dotNetProjectConfig.CompiledOutputName), null);
1165
1163
                                        aggregatedOperationMonitor.Dispose ();
1166
1164
                                }
1167
1165
                        } catch (Exception ex) {
 
1166
                                LoggingService.LogError (string.Format ("Cannot execute \"{0}\"", dotNetProjectConfig.CompiledOutputName), ex);
1168
1167
                                monitor.ReportError (GettextCatalog.GetString ("Cannot execute \"{0}\"", dotNetProjectConfig.CompiledOutputName), ex);
1169
1168
                        }
1170
1169
                }