How can you access the Visual Studio solution level platform from a C# project's build event?

后端 未结 5 1933
既然无缘
既然无缘 2020-12-11 02:07

We have a large VS 2010 solution that is mostly C# code but there are a few native DLLs that various C# projects depend upon (including our unit testing DLL). We\'re in the

5条回答
  •  盖世英雄少女心
    2020-12-11 02:41

    I don't think the 'Active Solution Configuration' has an equivalent macro property.

    What I suggest is to manually add a custom property in all .csproj files, like this (see the new MyVar custom property added for each configuration/platform combination):

    
      ...
      
        ...
        MyDebugAnyCpu
      
      
        ...
        MyReleaseAnyCpu
      
    

    You can use the 'Unload project' and 'Edit MyProject.csproj' menus to edit the .csprojet whil in Visual Studio. What's important to know is Visual Studio will not destroy these 'unknown' values even if you save it using the normal GUI editor.

    Then in the post build event, you can use these values, for example:

    copy $(SolutionDir)\$(MyVar)\$(Platform)\$(Configuration) $(TargetDir)
    

提交回复
热议问题