【发布时间】:2018-11-19 01:37:15
【问题描述】:
所以我可以很好地恢复和构建:
C:\xyz\MyApp [master ↑1]> git clean -qdfx
C:\xyz\MyApp [master ↑1]> msbuild /t:restore
Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 11/18/2018 8:24:37 PM.
Project "C:\xyz\MyApp\MyApp.sln" on node 1 (Restore target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Restore:
Restoring packages for C:\xyz\MyApp\MyApp\MyApp.csproj...
Restoring packages for C:\xyz\MyApp\MyAppFileTool\MyAppFileTool.csproj...
Restoring packages for C:\xyz\MyApp\MyAppHelper\MyAppHelper.csproj...
Committing restore...
Committing restore...
Committing restore...
Generating MSBuild file C:\xyz\MyApp\MyAppFileTool\obj\MyAppFileTool.csproj.nuget.g.props.
Generating MSBuild file C:\xyz\MyApp\MyApp\obj\MyApp.csproj.nuget.g.props.
Generating MSBuild file C:\xyz\MyApp\MyAppHelper\obj\MyAppHelper.csproj.nuget.g.props.
Generating MSBuild file C:\xyz\MyApp\MyAppFileTool\obj\MyAppFileTool.csproj.nuget.g.targets.
Generating MSBuild file C:\xyz\MyApp\MyApp\obj\MyApp.csproj.nuget.g.targets.
Generating MSBuild file C:\xyz\MyApp\MyAppHelper\obj\MyAppHelper.csproj.nuget.g.targets.
Writing lock file to disk. Path: C:\xyz\MyApp\MyApp\obj\project.assets.json
Writing lock file to disk. Path: C:\xyz\MyApp\MyAppFileTool\obj\project.assets.json
Writing lock file to disk. Path: C:\xyz\MyApp\MyAppHelper\obj\project.assets.json
Restore completed in 367.2 ms for C:\xyz\MyApp\MyAppHelper\MyAppHelper.csproj.
Restore completed in 367.46 ms for C:\xyz\MyApp\MyApp\MyApp.csproj.
Restore completed in 367.02 ms for C:\xyz\MyApp\MyAppFileTool\MyAppFileTool.csproj.
NuGet Config files used:
C:\Users\myself\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Done Building Project "C:\xyz\MyApp\MyApp.sln" (Restore target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.01
C:\xyz\MyApp [master ↑1]> msbuild /m /v:m
Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
MyAppHelper -> C:\xyz\MyApp\MyAppHelper\bin\Debug\MyAppHelper.dll
MyApp -> C:\xyz\MyApp\MyApp\bin\Debug\MyApp.exe
MyAppFileTool -> C:\xyz\MyApp\MyAppFileTool\bin\Debug\MyAppFileTool.exe
因此,我希望 pack 目标也可以工作,但事实并非如此:
C:\xyz\MyApp [master ↑1]> msbuild /t:pack
Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 11/18/2018 8:24:55 PM.
Project "C:\xyz\MyApp\MyApp.sln" on node 1 (pack target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "C:\xyz\MyApp\MyApp.sln" (1) is building "C:\xyz\MyApp\MyAppFileTool\MyAppFileTool.csproj" (2) on node 1 (pack target(s)).
C:\xyz\MyApp\MyAppFileTool\MyAppFileTool.csproj : error MSB4057: The target "pack" does not exist in the project.
Done Building Project "C:\xyz\MyApp\MyAppFileTool\MyAppFileTool.csproj" (pack target(s)) -- FAILED.
Project "C:\xyz\MyApp\MyApp.sln" (1) is building "C:\xyz\MyApp\MyApp\MyApp.csproj" (3) on node 1 (pack target(s)).
C:\xyz\MyApp\MyApp\MyApp.csproj : error MSB4057: The target "pack" does not exist in the project.
Done Building Project "C:\xyz\MyApp\MyApp\MyApp.csproj" (pack target(s)) -- FAILED.
Project "C:\xyz\MyApp\MyApp.sln" (1) is building "C:\xyz\MyApp\MyAppHelper\MyAppHelper.csproj" (4) on node 1 (pack target(s)).
C:\xyz\MyApp\MyAppHelper\MyAppHelper.csproj : error MSB4057: The target "pack" does not exist in the project.
Done Building Project "C:\xyz\MyApp\MyAppHelper\MyAppHelper.csproj" (pack target(s)) -- FAILED.
Done Building Project "C:\xyz\MyApp\MyApp.sln" (pack target(s)) -- FAILED.
Build FAILED.
"C:\xyz\MyApp\MyApp.sln" (pack target) (1) ->
"C:\xyz\MyApp\MyAppFileTool\MyAppFileTool.csproj" (pack target) (2) ->
C:\xyz\MyApp\MyAppFileTool\MyAppFileTool.csproj : error MSB4057: The target "pack" does not exist in the project.
"C:\xyz\MyApp\MyApp.sln" (pack target) (1) ->
"C:\xyz\MyApp\MyApp\MyApp.csproj" (pack target) (3) ->
C:\xyz\MyApp\MyApp\MyApp.csproj : error MSB4057: The target "pack" does not exist in the project.
"C:\xyz\MyApp\MyApp.sln" (pack target) (1) ->
"C:\xyz\MyApp\MyAppHelper\MyAppHelper.csproj" (pack target) (4) ->
C:\xyz\MyApp\MyAppHelper\MyAppHelper.csproj : error MSB4057: The target "pack" does not exist in the project.
0 Warning(s)
3 Error(s)
Time Elapsed 00:00:00.27
C:\xyz\MyApp [master ↑1]>
怎么了?
编辑 1
我刚刚创建了一个新的 .NET Standard 项目,restore 和 pack 都可以正常工作。有问题的解决方案是我在 Visual Studio 2017 的帮助下转换为使用 PackageReference 的 .NET Framework 4.7.2 解决方案。我没有手动执行任何操作。
【问题讨论】:
-
为什么需要添加msbuild社区任务? msbuild 15 不应该开箱即用地支持它吗?
restore目标有效,因此显然有 NuGet 支持。
标签: msbuild visual-studio-2017 nuget