Visual Studio 设置项目预构建事件

发布于 2024-12-03 02:47:26 字数 300 浏览 0 评论 0原文

我有一个 Visual Studio 安装项目,其中一些部署的文件是由预构建事件创建的。但是,当我构建项目时,Visual Studio 首先进行预构建验证,然后运行预构建事件。因此,预构建验证失败,并显示错误消息“错误:无法找到文件...”。

有谁知道这个问题的解决方法?

(细节可能并不重要,但它是 Python 应用程序的 Windows Installer。预构建事件调用 PyInstaller,它将 py 文件打包为单个 exe 文件。然后,该 exe 文件以及一些 DLL 和资源文件由将项目设置为 Windows Installer。)

I have a Visual Studio Setup project where some of the deployed files are created by a pre-build event. However, when I build the project Visual Studio first does pre-build validation and then runs the pre-build event. Thus pre-build validation fails, with the error message "ERROR: Unable to find file ...".

Does anyone know a work-around for this?

(The details may not matter, but it is a Windows Installer for a Python app. The pre-build event calls PyInstaller which packages the py files as a single exe file. This exe file and some DLL's and resource files are then packaged by the Setup project as a Windows Installer.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别低头,皇冠会掉 2024-12-10 02:47:26

您必须能够使用 MSBuild 目标而不是预构建事件。我不确定具体细节,但我猜想以下 链接 可能会解释您的类似情况。

编辑 - 2017 年 7 月(由于重新定位链接):
http://pradeepc.net/using- tfs-teambuild-to-build-setup-projects-in-visual-studio

从该链接复制的示例粘贴在下面 - 您可能需要进行编辑以满足需要:

<Target Name="AfterDropBuild">
   <Exec Command="devenv.exe MySolution.sln /Build &quot;Release|Any CPU&quot;" WorkingDirectory="$(SolutionRoot)" />
   <ItemGroup>
      <SetupFiles Include="$(SolutionRoot)/MySetup/Release/MySetup.msi" />
      <SetupFiles Include="$(SolutionRoot)/MySetup/Release/Setup.exe" />
   </ItemGroup>
   <Copy SourceFiles="@(SetupFiles)" DestinationFolder="\Build-MachineBuild_Drop_FoldersMyProjectMSI$(BuildNumber)" />
   <Copy SourceFiles="@(SetupFiles)" DestinationFolder="\Build-MachineBuild_Drop_FoldersMyProjectMSILatest_MSI" />
</Target>

You must be able to use MSBuild Targets instead of a Prebuild Event. I am not sure about the specifics, but I guess the following link might explain your similar situation.

Edited - July 2017 (due to relocated link):
http://pradeepc.net/using-tfs-teambuild-to-build-setup-projects-in-visual-studio

Sample copied from that link is pasted below - you may want to edit to fit the need:

<Target Name="AfterDropBuild">
   <Exec Command="devenv.exe MySolution.sln /Build &quot;Release|Any CPU&quot;" WorkingDirectory="$(SolutionRoot)" />
   <ItemGroup>
      <SetupFiles Include="$(SolutionRoot)/MySetup/Release/MySetup.msi" />
      <SetupFiles Include="$(SolutionRoot)/MySetup/Release/Setup.exe" />
   </ItemGroup>
   <Copy SourceFiles="@(SetupFiles)" DestinationFolder="\Build-MachineBuild_Drop_FoldersMyProjectMSI$(BuildNumber)" />
   <Copy SourceFiles="@(SetupFiles)" DestinationFolder="\Build-MachineBuild_Drop_FoldersMyProjectMSILatest_MSI" />
</Target>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文