Skip to content

Commit cf664cb

Browse files
committed
Fixed possible "Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))"
1. Do not use the `.Save();` on `EProject` because of possible "File Modification Detected ... has been modified outside the environment." 2. Do not use `.Save();` on `DProject` because of possible "Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))" For DProject it also activates "Save As" dialog in VS even inside try/catch
1 parent c68aea2 commit cf664cb

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

vsSolutionBuildEvent/MSBuild/Parser.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,27 @@ public virtual string evaluate(string unevaluated, string projectName = null)
165165
CultureInfo origincul = Thread.CurrentThread.CurrentCulture;
166166
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
167167

168-
try {
168+
try
169+
{
170+
// To fix "Save changes to the following items"
171+
project.DisableMarkDirty = true;
172+
169173
defProperties(project);
170174
project.SetProperty(container, Tokens.characters(_wrapProperty(ref unevaluated)));
171175
return project.GetProperty(container).EvaluatedValue;
172176
}
173-
finally {
177+
finally
178+
{
174179
project.RemoveProperty(project.GetProperty(container));
180+
project.DisableMarkDirty = false;
181+
175182
Thread.CurrentThread.CurrentCulture = origincul;
176183

177-
// To fix "Save changes to the following items?"
178-
// Do not use the `project.Save();` because will be "File Modification Detected ... has been modified outside the environment."
179-
foreach(var dteprj in Env.ProjectsDTE.Where(p => p.FullName == project.FullPath)) {
180-
dteprj.Save();
181-
}
184+
// NOTE: about other solutions for "Save changes to the following items":
185+
186+
// 1) Do not use the `.Save();` on `EProject` because of possible "File Modification Detected ... has been modified outside the environment."
187+
// 2) Do not use `.Save();` on `DProject` because of possible "Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))"
188+
// For DProject it also activates "Save As" dialog in VS even inside try/catch
182189
}
183190
}
184191
}

0 commit comments

Comments
 (0)