English 中文(简体)
Visual Studio自动化:以编程方式获取项目输出目录
原标题:Visual Studio Automation: Programatically get a project output directory

I want to programatically get a project output directory in a Visual Studio macro.
I managed to get a string of the path (through prj.ConfigurationManager.ActiveConfiguration.Properties and looking at property OutputDirectory) but this string may contain macros such as $(foo) where foo is defined in a property sheet or whatnot.

我如何解决该产出目录上的实际目录?

最佳回答

我为我的宏编写了这个函数,它通过子字符串查找完整的绝对输出路径。

Function FindOutBinaryNameByExtension(ByVal prj As EnvDTE.Project, ByVal extName As String) As String
    FindOutBinaryNameByExtension = Nothing

    Dim cm As ConfigurationManager = prj.ConfigurationManager
    If cm IsNot Nothing Then
        Dim ac As Configuration = cm.ActiveConfiguration
        For Each grpOut In ac.OutputGroups
            If grpOut.DisplayName = "Primary output" Then
                Dim lst As Array = grpOut.FileURLs
                For i As Long = 0 To lst.Length - 1
                    Dim fileName As String = lst.GetValue(i)
                    If fileName.Contains(extName) Then
                        FindOutBinaryNameByExtension = fileName
                        Exit Function
                    End If
                Next
            End If
        Next
    End If
End Function
问题回答

暂无回答




相关问题
building .net applications without Visual Studio

I m interested to hear about people working with building .net applications using MSBuild, NAnt or similar tools. What are you using, why are you using it instead of the VS IDE? I like to use ...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Visual Studio 2010 Beta 2: Can I print in color?

I have to turn in a hard copy of some code with an assignment. Is there any way in Visual Studio 2010 to print C# source code with syntax highlighting? PS: The assignment is solving a math problem, ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

热门标签