[英]VStudio always compiles all the TargetFrameworks for referenced multi-target projects, whatever head is specified for a build in Uno-platform solution
I'm working on a cross-platform application using the Uno Platform.我正在使用 Uno 平台开发跨平台应用程序。 The app consists of 5 standard head projects for my App and a dozen of referenced cross-platform libraries projects (Uno-platform cross-platform library projects, MSBuild.Sdk.Extras, VStudio 2019).该应用程序包含我的应用程序的 5 个标准头项目和十几个引用的跨平台库项目(Uno 平台跨平台库项目,MSBuild.Sdk.Extras,VStudio 2019)。 Referenced project libraries have multi-target frameworks specified like: netstandard2.0;xamarinios10;xamarinmac20;MonoAndroid90;monoandroid10.0.引用的项目库具有指定的多目标框架,例如:netstandard2.0;xamarinios10;xamarinmac20;MonoAndroid90;monoandroid10.0。 Solution structure looks like this:解决方案结构如下所示:
- SolutionApp
- App.Droid
- App.iOS
- App.macOS
- App.UWP
- App.Wasm
- App.Shared
- MultiTargetLibrary1
...
- MultiTargetLibraryN
The problem is that each time I rebuild any of the head app projects, VStudio rebuilds referenced projects for all the target frameworks available.问题是每次我重建任何头部应用程序项目时,VStudio 都会为所有可用的目标框架重建引用的项目。
How to avoid a compilation of unnecessary target platforms?如何避免编译不必要的目标平台? How can a referenced project get which head project has triggered a build?引用的项目如何获得哪个头部项目触发了构建? Is there any possibility to pass which exact target framework is needed in referenced project building from VStudio?是否有可能通过 VStudio 的引用项目构建中需要哪个确切的目标框架?
Example: I choose to rebuild App.iOS and it triggered a rebuild of referenced projects.示例:我选择重建 App.iOS,它触发了引用项目的重建。 I want projects with only 'xamarinios10' TargetFramework to be built.我想要构建只有“xamarinios10”TargetFramework 的项目。
If there are only a few target frameworks or projects compilation isn't slow, but with an increasing amount of referenced projects time extremely grows.如果只有几个目标框架或项目,编译并不慢,但随着引用项目数量的增加,时间会大大增加。
As I've got from msbuild reference: VStudio calls msbuild for each project on solution separately, so msbuild doesn't know which head project has triggered the build of the referenced project and which target platform is required.正如我从 msbuild 参考资料中得到的那样:VStudio 分别为解决方案上的每个项目调用 msbuild,所以 msbuild 不知道哪个头项目触发了引用项目的构建以及哪个目标平台。
This is a known Visual Studio 2019 issue , where all targets are built regardless of the actual head project being compiled.这是一个已知的Visual Studio 2019 问题,无论正在编译的实际头项目如何,都会构建所有目标。
In the meantime, you can manually exclude some target frameworks when building the application, and use the solution filter feature of Visual Studio so that nuget does not complain about invalid project references.同时,您可以在构建应用程序时手动排除一些目标框架,并使用 Visual Studio 的解决方案过滤功能,使 nuget 不会抱怨无效的项目引用。 That way, you can make 4 filters, with each excluding the projects that are not used for the platform you're currently working on.这样,您可以制作 4 个过滤器,每个过滤器都排除了不用于您当前正在处理的平台的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.