【问题标题】:I have a error building a .vdproj on msbuild with nant我在使用 nant 在 msbuild 上构建 .vdproj 时出错
【发布时间】:2010-12-01 02:54:52
【问题描述】:

我已经习惯于使用 nant 来构建版本。但我已经开始使用 asp.net MVC,我选择使用 .vdproj 进行安装设置。

但是,当我调用:



在 nant 中,我的结果是:

[exec] D:\My Documents\Visual Studio 2008\Projects\Wum\Wum.sln:警告 MS
B4078:MSBuild 不支持项目文件“Wum.Setup\Wum.Setup.vdproj”
并且无法构建。

有人有一些线索或解决方案吗?

如果我使用 devenv,我会遇到问题吗?

【问题讨论】:

    标签: c# msbuild build nant vdproj


    【解决方案1】:

    这是我最近使用 devenv 执行此操作的方法,因为 msbuild 不会执行 .vdproj 文件。这篇文章确实有助于首先更新 .vdproj 文件:http://www.hanselman.com/blog/BuildingMSIFilesFromNAntAndUpdatingTheVDProjsVersionInformationAndOtherSinsOnTuesday.aspx

    <target name="someTarget">
        <!-- full path to setup project and project file (MSI -> vdproj) -->
        <property name="DeploymentProjectPath" value="fullPath\proj.vdproj" />
        <!-- full path to source project and project file (EXE -> csproj) -->
        <property name="DependencyProject" value="fullPath\proj.csproj" />
        <script language="C#">
        <code>
          <![CDATA[
            public static void ScriptMain(Project project)
            {
                //Purpose of script: load the .vdproj file, replace ProductCode and PackageCode with new guids, and ProductVersion with 1.0.SnvRevisionNo., write over .vdproj file
    
                string setupFileName = project.Properties["DeploymentProjectPath"];
                string productVersion = string.Format("1.0.{0}", project.Properties["svn.revision"]);
                string setupFileContents;
    
                //read in the .vdproj file          
                using (StreamReader sr = new StreamReader(setupFileName))
                {
                    setupFileContents = sr.ReadToEnd();
                }
    
                if (!string.IsNullOrEmpty(setupFileContents))
                {
                    Regex expression2 = new Regex(@"(?:\""ProductCode\"" = \""8.){([\d\w-]+)}");
                    Regex expression3 = new Regex(@"(?:\""PackageCode\"" = \""8.){([\d\w-]+)}");
                    Regex expression4 = new Regex(@"(?:\""ProductVersion\"" = \""8.)(\d.\d.\d+)");
                    setupFileContents = expression2.Replace(setupFileContents,"\"ProductCode\" = \"8:{" + Guid.NewGuid().ToString().ToUpper() + "}");
                    setupFileContents = expression3.Replace(setupFileContents,"\"PackageCode\" = \"8:{" + Guid.NewGuid().ToString().ToUpper() + "}");
                    setupFileContents = expression4.Replace(setupFileContents,"\"ProductVersion\" = \"8:" + productVersion);
    
                    using (TextWriter tw = new StreamWriter(setupFileName, false))
                    {
                        tw.WriteLine(setupFileContents);
                    }
                }
            }
           ]]>
        </code>
        </script>
    
        <!-- must build the dependency first (code project), before building the MSI deployment project -->
        <exec program="Devenv.exe" commandline='"fullPath\solution.sln" /rebuild "Release" /project "${DependencyProject}" /out "fullPath\somelog.log"'/>
        <exec program="Devenv.exe" commandline='"fullPath\solution.sln" /rebuild "Release" /project "${DeploymentProjectPath}" /out "fullPath\somelog.log"'/>
    </target>
    

    【讨论】:

    • @GarrisonNeely 你试过像%DevEnv% "%BaseSln%" /build "%BuildConfiguration%|%BuildPlatform%" /Project "%BaseVdproj%" /Out "vs_errors.txt" 这样的脚本吗?
    • 也适用 MSBuild 脚本 (*.targets) ?
    【解决方案2】:

    MSBuild 无法构建 .vdproj 项目。您应该为此使用 Visual Studio (devenv.com)。

    【讨论】:

    • ... 或从 Visual Studio .NET 设置和部署项目转移到 VS 2010 中将支持的 WiX。
    • 为什么 MSBuild 不能构建 .vdproj 项目? MSDN 中有完整的参考资料吗?无论如何,Wix 有非常大的学习曲线
    • @TheChairman Wix 有非常大的学习曲线,微软在 VS 2013、VS 2015 和 VS 2017 中有 Visual Studio Extensions for Installer Projects
    【解决方案3】:

    仅供参考,.NET 4.0 仍然不支持此功能

    【讨论】:

      【解决方案4】:

      只是为了扩展 CRise 的帖子 - 通过命令行使用 VS2010 devenv 构建 vdproj 项目不起作用。我相信 2010 年前的工作正常(请参阅 link text

      【讨论】:

      • 看起来有一些问题,我使用的是 2008 年。Microsoft 已声明“目前估计该修补程序是 8 月中旬。”
      猜你喜欢
      • 2012-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-03
      • 2011-07-07
      • 2010-10-06
      • 1970-01-01
      相关资源
      最近更新 更多