3

I'm trying to work on a Visual Studio Extension that needs to add a property that gets persisted to the current csproj file like so:

    <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MyProperty Condition="$(MyProperty) == '' Or $(MyProperty) == '*Undefined*'">MyPropertyValue</MyProperty>

I have an ENVDTE.Project instance, but can't seem to find anywhere in the API to add a new property to the project.

I'm able to work around the issue by converting it to an MSBuild project and adding the property that way, but that approach causes the user to get prompted that the csproj file has been modified outside of the IDE and asks them to re-load, which I don't want.

How can I either add the property with the ENVDTE.Project instance, or prevent the 'Modified outside the environment' prompt from showing up in some other way?

Craig Vermeer
  • 1,987
  • 19
  • 29

1 Answers1

2

Got my issue resolved with the MSBuild project workaround.

The issue that was causing the user to get prompted that the project file had changed was that I was calling .Save() on my MSBuild project object, and not my ENVDTE project object.

Craig Vermeer
  • 1,987
  • 19
  • 29
  • 1
    Could you elaborate on your solution? I'm trying to see if I can use your solution to get me on my way for this: http://stackoverflow.com/questions/20267268/add-code-analisys-ruleset-through-nuget-package – Boris Callens Nov 28 '13 at 13:51