locked
•SDK Package and MSBuild: New Reference Node RRS feed

  • Question

  • I want to create a new type of reference node for c# project type, the idea is that the new reference type recognizes if the assembly exists on the visual studio and creates project reference or otherwise creates assembly reference.

    I want to know if this is possible, if I understand right those are the things I need to cover:

    ·         Hook the right click on the project and on the references folder and display my context menu.

    ·         Create my reference node and add it to the c# project references.

    ·         Create new msbuild build action called MyReference

    ·         Create new task which resolve the reference and add it to the ReferencePath item.

    Let me know if this is possible and how can I do it?

    Thanks.

     

    Thursday, April 22, 2010 10:27 PM

Answers

  • Hi Somdoron,

    Thanks for your post.

    Based on my understanding, your logic is fine. You can hook Project.AddReference command, and before executing it, you can do your custom actions. But I do not try it.

    Please check a similiar question as yours, maybe it will give you some hints:

    How to add a reference node in a custom project

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Tuesday, May 11, 2010 3:20 AM
    Monday, April 26, 2010 5:48 AM

All replies

  • Hi Somdoron,

    Thanks for your post.

    Based on my understanding, your logic is fine. You can hook Project.AddReference command, and before executing it, you can do your custom actions. But I do not try it.

    Please check a similiar question as yours, maybe it will give you some hints:

    How to add a reference node in a custom project

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Tuesday, May 11, 2010 3:20 AM
    Monday, April 26, 2010 5:48 AM
  • Hi Nancy,

    Thanks for both answers, I need to take a look at wix but i'm not sure i can change or expand the package of vcproj, or maybe I can?

    Right now if the ProjectReference or Reference is not in the csproj visual studio intellisense and winforms designers are not working good.

    I came up with another solution but it little bit ugly because for each reference you need 10 lines of code:

      <UsingTask TaskName="IsProjectInsideSolution" ... />
     
      <Target Name="SetReferences">
        <IsProjectInsideSolution ReferenceName="SomeProject">
          <Output TaskParameter="IsInsideSolution" PropertyName="IsSomeProjectInsideSolution" />
        </IsProjectInsideSolution>

        <ItemGroup>
          <ProjectReference Condition="'$(IsSomeProjectInsideSolution)' == 'true'" ...>
            ....
          </ProjectReference>
          <Reference Condition="'$(IsSomeProjectInsideSolution)' == 'false'" ...>
            ....
          </Reference>
        </ItemGroup>
       
      </Target>

    The idea is something like maven, when the project is not inside visual studio i want to reference the assembly from remote repository (build by some build server), but when the project is inside visual studio i want to reference the project within visual studio to make the debugging and the development easier.

    Also I want to decouple solutions from projects, I want the solutions to be only saved workspaces (not even in source control, only saved locally by the programmer).

    When the developer starts to work on a project he only has the main project inside visual studio and all references are to the remote repository. When the developer decide he wants to edit or to find a bug in a framework project he loads the project inside visual studio, now the reference is to the visual studio project, when the developer change something in the framework project and commits after some mintutes the build server build the framework project and update the remote repository and the change is available to the other developers which are not referencing the project from inside visual studio.

    Any other idea how to solve the reference problem? I want something which is not complicated to work with and which will work perfect with visual studio and msbuild.

    Thanks

    Wednesday, April 28, 2010 10:02 AM
  • Hi Somdoron,

    I will close this thread here, and will answer the question you ask in second reply in your other thread with following link:

    http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/8b036235-8202-4dbf-9c9e-7dcbd27d81f3

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, May 3, 2010 9:33 AM