MsBuild 任务在 csproj 文件中失败,但在命令行中成功
MsBuild task fails in csproj file but succeeds on the command line
我正在尝试在构建安装程序项目时使用特定配置构建我的解决方案中的其他项目。在 Installer.csproj
我有以下内容:
<Target Name="BuildProjects" AfterTargets="Build">
<MSBuild Projects="$(SolutionPath)" Targets="Applications\ProjectName"
Properties='Configuration="Debug 2019";Platform="Any CPU";OutputPath=$(TargetDir)ProjectName/'>
</MSBuild>
</Target>
此操作失败并在输出中显示一条消息:
C:\Users\path\to\Solution.sln.metaproj : error MSB4057: The target "Applications\ProjectName" does not exist in the project.
但是,如果我 运行 在开发人员命令提示符下执行以下命令,它会起作用:
msbuild C:\Users\path\to\Solution.sln -t:Applications\ProjectName -p:Configuration="Debug 2019";Platform="Any CPU";OutputPath=C:\Users\path\to\Installer\bin\Debug 2019\ProjectName\
据我所知,它们说的是同一件事。作为临时解决方案,我可以 运行 执行任务中的命令,但我想利用 MSBuild 任务。
好的,这只是我缺少 understanding/reading MSBuild 任务文档。据我所知,Targets
属性 与 msbuild.exe 中的 -t 标志不对应。我在以下方面取得了更大的成功:
<MSBuild Projects="$(SolutionPath)Applications\ProjectName.csproj"
Properties="Configuration='Debug 2019';Platform='Any CPU';OutputPath=$(TargetDir)ProjectName/">
</MSBuild>
我正在尝试在构建安装程序项目时使用特定配置构建我的解决方案中的其他项目。在 Installer.csproj
我有以下内容:
<Target Name="BuildProjects" AfterTargets="Build">
<MSBuild Projects="$(SolutionPath)" Targets="Applications\ProjectName"
Properties='Configuration="Debug 2019";Platform="Any CPU";OutputPath=$(TargetDir)ProjectName/'>
</MSBuild>
</Target>
此操作失败并在输出中显示一条消息:
C:\Users\path\to\Solution.sln.metaproj : error MSB4057: The target "Applications\ProjectName" does not exist in the project.
但是,如果我 运行 在开发人员命令提示符下执行以下命令,它会起作用:
msbuild C:\Users\path\to\Solution.sln -t:Applications\ProjectName -p:Configuration="Debug 2019";Platform="Any CPU";OutputPath=C:\Users\path\to\Installer\bin\Debug 2019\ProjectName\
据我所知,它们说的是同一件事。作为临时解决方案,我可以 运行 执行任务中的命令,但我想利用 MSBuild 任务。
好的,这只是我缺少 understanding/reading MSBuild 任务文档。据我所知,Targets
属性 与 msbuild.exe 中的 -t 标志不对应。我在以下方面取得了更大的成功:
<MSBuild Projects="$(SolutionPath)Applications\ProjectName.csproj"
Properties="Configuration='Debug 2019';Platform='Any CPU';OutputPath=$(TargetDir)ProjectName/">
</MSBuild>