49
49
namespace MonoDevelop.Projects
51
51
[DataInclude(typeof(DotNetProjectConfiguration))]
52
[ProjectModelDataItem ("AbstractDotNetProject")]
52
53
public abstract class DotNetProject : Project, IAssemblyProject
137
138
if ((projectOptions != null) && (projectOptions.Attributes["TargetFrameworkVersion"] != null))
138
targetFrameworkVersion = projectOptions.Attributes["TargetFrameworkVersion"].Value;
139
targetFrameworkId = TargetFrameworkMoniker.Parse (projectOptions.Attributes["TargetFrameworkVersion"].Value);
141
142
if (projectCreateInfo != null) {
291
292
if (targetFramework == validValue || validValue == null)
293
294
targetFramework = validValue;
294
targetFrameworkVersion = validValue.Id;
295
targetFrameworkId = validValue.Id;
295
296
if (replacingValue)
296
297
UpdateSystemReferences ();
297
298
NotifyModified ("TargetFramework");
301
302
public TargetRuntime TargetRuntime {
302
303
get { return Runtime.SystemAssemblyService.DefaultRuntime; }
306
public virtual TargetFrameworkMoniker GetDefaultTargetFrameworkId ()
308
return ProjectService.DefaultTargetFrameworkId;
305
311
public IAssemblyContext AssemblyContext {
325
331
void SetDefaultFramework ()
327
333
if (targetFramework == null) {
328
if (targetFrameworkVersion != null)
329
targetFramework = Runtime.SystemAssemblyService.GetTargetFramework (targetFrameworkVersion);
334
if (targetFrameworkId != null)
335
targetFramework = Runtime.SystemAssemblyService.GetTargetFramework (targetFrameworkId);
330
336
if (targetFramework == null)
331
337
TargetFramework = Services.ProjectService.DefaultTargetFramework;
383
389
public override void Dispose ()
386
if (composedAssemblyContext != null)
391
if (composedAssemblyContext != null) {
387
392
composedAssemblyContext.Dispose ();
393
// composedAssemblyContext = null;
396
// languageParameters = null;
397
// privateAssemblyContext = null;
398
// currentRuntimeContext = null;
399
// languageBinding = null;
400
// projectReferences = null;
388
402
Runtime.SystemAssemblyService.DefaultRuntimeChanged -= RuntimeSystemAssemblyServiceDefaultRuntimeChanged;
389
403
FileService.FileRemoved -= OnFileRemoved;
392
408
public virtual bool SupportsPartialTypes {
417
433
internal override void OnFileChanged (object source, MonoDevelop.Core.FileEventArgs e)
435
// The OnFileChanged handler is unsubscibed in the Dispose method, so in theory we shouldn't need
436
// to check for disposed here. However, it might happen that this project is disposed while the
437
// FileService.FileChanged event is being dispatched, in which case the event handler list is already
438
// cached and won't take into account unsubscriptions until the next dispatch
419
442
base.OnFileChanged (source, e);
420
CheckReferenceChange (e.FileName);
443
foreach (FileEventInfo ei in e)
444
CheckReferenceChange (ei.FileName);
449
473
return base.OnRunTarget (monitor, target, configuration);
452
protected override void PopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration)
476
internal protected override void PopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration)
454
478
base.PopulateOutputFileList (list, configuration);
455
479
DotNetProjectConfiguration conf = GetConfiguration (configuration) as DotNetProjectConfiguration;
508
static int supportReferDistance = -1;
483
protected override void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration)
510
internal protected override void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration)
485
PopulateSupportFileList (list, configuration, 0);
513
supportReferDistance++;
514
PopulateSupportFileListInternal (list, configuration);
516
supportReferDistance--;
488
void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration, int referenceDistance)
520
void PopulateSupportFileListInternal (FileCopySet list, ConfigurationSelector configuration)
490
if (referenceDistance < 2)
522
if (supportReferDistance < 2)
491
523
base.PopulateSupportFileList (list, configuration);
493
525
//rename the app.config file
494
FileCopySet.Item appConfig = list.Remove ("app.config");
495
if (appConfig == null)
496
appConfig = list.Remove ("App.config");
526
list.Remove ("app.config");
527
list.Remove ("App.config");
529
ProjectFile appConfig = Files.FirstOrDefault (f => f.FilePath.FileName.Equals ("app.config", StringComparison.CurrentCultureIgnoreCase));
497
530
if (appConfig != null) {
498
string output = Path.GetFileName (GetOutputFileName (configuration));
499
list.Add (appConfig.Src, appConfig.CopyOnlyIfNewer, output + ".config");
531
string output = GetOutputFileName (configuration).FileName;
532
list.Add (appConfig.FilePath, true, output + ".config");
502
535
//collect all the "local copy" references and their attendant files
523
556
//VS COMPAT: recursively copy references's "local copy" files
524
557
//but only copy the "copy to output" files from the immediate references
525
p.PopulateSupportFileList (list, configuration, referenceDistance + 1);
558
foreach (var f in p.GetSupportFileList (configuration))
559
list.Add (f.Src, f.CopyOnlyIfNewer, f.Target);
527
561
DotNetProjectConfiguration refConfig = p.GetConfiguration (configuration) as DotNetProjectConfiguration;
537
571
// VS COMPAT: Copy the assembly, but also all other assemblies referenced by it
538
572
// that are located in the same folder
539
573
foreach (string file in GetAssemblyRefsRec (projectReference.Reference, new HashSet<string> ())) {
574
// Indirectly referenced assemblies are only copied if a newer copy doesn't exist. This avoids overwritting directly referenced assemblies
575
// by indirectly referenced stale copies of the same assembly. See bug #655566.
576
bool copyIfNewer = file != projectReference.Reference;
577
list.Add (file, copyIfNewer);
541
578
if (File.Exists (file + ".config"))
542
list.Add (file + ".config");
579
list.Add (file + ".config", copyIfNewer);
543
580
string mdbFile = TargetRuntime.GetAssemblyDebugInfoFile (file);
544
581
if (File.Exists (mdbFile))
582
list.Add (mdbFile, copyIfNewer);
548
585
else if (projectReference.ReferenceType == ReferenceType.Custom) {
1028
protected internal override void OnItemAdded (object obj)
1065
protected internal override void OnItemsAdded (IEnumerable<ProjectItem> objs)
1030
base.OnItemAdded (obj);
1031
if (obj is ProjectReference) {
1032
ProjectReference pref = (ProjectReference)obj;
1067
base.OnItemsAdded (objs);
1068
foreach (var pref in objs.OfType<ProjectReference> ()) {
1033
1069
pref.SetOwnerProject (this);
1034
1070
NotifyReferenceAddedToProject (pref);
1038
protected internal override void OnItemRemoved (object obj)
1074
protected internal override void OnItemsRemoved (IEnumerable<ProjectItem> objs)
1040
base.OnItemRemoved (obj);
1041
if (obj is ProjectReference) {
1042
ProjectReference pref = (ProjectReference)obj;
1076
base.OnItemsRemoved (objs);
1077
foreach (var pref in objs.OfType<ProjectReference> ()) {
1043
1078
pref.SetOwnerProject (null);
1044
1079
NotifyReferenceRemovedFromProject (pref);
1080
1115
private void OnFileRemoved (Object o, FileEventArgs e)
1082
CheckReferenceChange (e.FileName);
1117
foreach (FileEventInfo ei in e)
1118
CheckReferenceChange (ei.FileName);
1085
1121
protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)