Граф коммитов

87 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Peppers c207c6716d [XamlC] should not run during Design-Time Builds (#3034)
Some links about design-time builds:
- https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md
- https://daveaglick.com/posts/running-a-design-time-build-with-msbuild-apis

In Visual Studio 2017 (Windows), a "design-time" build is what drives
Intellisense in cases such as using `x:Name` in XAML (or
`Resource.designer.cs` in a plain Xamarin.Android app). Improving our
"design-time" build speed will improve general performance in the IDE
such as project load and how long Intellisense takes to update. Since
XamlC is not needed during a design-time build, it is an "easy-win" to
just disable it. XamlC can take a bit of time for projects with a lot
of XAML.

This might also help with: https://github.com/xamarin/Xamarin.Forms/issues/3004

Although we should probably not do anything to specifically support
NCrunch; hopefully, NCrunch is running under the context of a
design-time build.
2018-06-15 15:34:11 +01:00
Stephane Delcroix 44182014ad
CSSG Incremental (#2940)
* CSSG Incremental

* [tests] MSBuild integration tests for CssG
2018-06-11 11:56:17 +02:00
Stephane Delcroix 012d248e2a Merge branch '3.0.0' into 3.1.0 2018-05-29 10:18:13 +02:00
Jason Smith b84b35bb5f [XamlG] builds incrementally, add MSBuild integration tests (#2825)
* [XamlG] builds incrementally, add MSBuild integration tests

Context: https://github.com/xamarin/Xamarin.Forms/pull/2230

The main performance problem with the collection of MSBuild targets in
`Xamarin.Forms.targets` is they don't build incrementally. I addressed
this with `XamlC` using a "stamp" file; however, it is not quite so
easy to setup the same thing with `XamlG`.

They way "incremental" builds are setup in MSBuild, is by specifying
the `Inputs` and `Outputs` of a `<Target />`. MSBuild will partially
build a target when some outputs are not up to date, and skip it
entirely if they are all up to date.

The best docs I can find on MSBuild incremental builds:
https://msdn.microsoft.com/en-us/library/ms171483.aspx

Unfortunately a few things had to happen to make this work for
`XamlG`:
- Define a new target `_FindXamlGFiles` that is invoked before `XamlG`
- `_FindXamlGFiles` defines the `_XamlGInputs` and `_XamlGOutputs`
  `<ItemGroup />`'s
- `_FindXamlGFiles` must also define `<Compile />` and `<FileWrites />`,
  in case the `XamlG` target is skipped
- `XamlGTask` now needs to get passed in a list of `OutputFiles`,
  since we have computed these paths ahead of time
- `XamlGTask` should validate the lengths of `XamlFiles` and
  `OutputFiles` match, used error message from MSBuild proper:
  a691a44f0e/src/Tasks/Copy.cs (L505)

`XamlG` now builds incrementally!

To give some context on how much improvement we can see with build
times, consider the following command:

    msbuild Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj

If you run it once, it will take a while--this change will not improve
the first build. On the second build with the exact same command, it
*should* be much faster.

Before this commit, the second build on my machine takes:

    40.563s

After the change:

    23.692s

`XamlG` has cascading impact on build times when it isn't built
incrementally:
- The C# assembly always changes
- Hence, `XamlC` will always run
- Hence, `GenerateJavaStubs` will always run
- Hence, `javac.exe` and `dx.jar` will always run

I am making other improvements like this in Xamarin.Android itself,
that will further improve these times, such as:
https://github.com/xamarin/xamarin-android/pull/1693

~~ New MSBuild Integration Tests ~~

Added some basic MSBuild testing infrastructure:
- Tests write project files to `bin/Debug/temp/TestName`
- Each test has an `sdkStyle` flag for testing the new project system
  versus the old one
- `[TearDown]` deletes the entire directory, with a retry for
  `IOException` on Windows
- Used the `Microsoft.Build.Locator` NuGet package for locating
  `MSBuild.exe` on Windows
- These tests take 2-5 seconds each

So for example, the simplest test, `BuildAProject` writes to
`Xamarin.Forms.Xaml.UnitTests\bin\Debug\temp\BuildAProject(False)\test.csproj`:

    <?xml version="1.0" encoding="utf-8"?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration>Debug</Configuration>
        <Platform>AnyCPU</Platform>
        <OutputType>Library</OutputType>
        <OutputPath>bin\Debug</OutputPath>
        <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="mscorlib" />
        <Reference Include="System" />
        <Reference Include="Xamarin.Forms.Core.dll">
          <HintPath>..\..\Xamarin.Forms.Core.dll</HintPath>
        </Reference>
        <Reference Include="Xamarin.Forms.Xaml.dll">
          <HintPath>..\..\Xamarin.Forms.Xaml.dll</HintPath>
        </Reference>
      </ItemGroup>
      <ItemGroup>
        <Compile Include="AssemblyInfo.cs" />
      </ItemGroup>
      <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
      <Import Project="..\..\..\..\..\.nuspec\Xamarin.Forms.targets" />
      <ItemGroup>
        <EmbeddedResource Include="MainPage.xaml" />
      </ItemGroup>
    </Project>

Invokes `msbuild`, and checks the intermediate output for files being
generated.

Tested scenarios:
- Build a simple project
- Build, then build again, and make sure targets were skipped
- Build, then clean, make sure files are gone
- Build, with linked files
- Design-time build
- Call `UpdateDesignTimeXaml` directly
- Build, add a new file, build again
- Build, update timestamp on a file, build again
- XAML file with random XML content
- XAML file with invalid XML content
- A general `EmbeddedResource` that shouldn't go through XamlG

Adding these tests found a bug! `IncrementalClean` was deleting
`XamlC.stamp`. I fixed this by using `<ItemGroup />`, which will be
propery evaluated even if the target is skipped.

~~ Other Changes ~~

- `FilesWrite` is actually supposed to be `FileWrites`, see canonical
  source of how `Clean` works and what `FileWrites` is here:
  https://github.com/Microsoft/msbuild/issues/2408#issuecomment-321082997
- Moved `DummyBuildEngine` into `MSBuild` directory--makes sense?
  maybe don't need to?
- Added a `XamlGDifferentInputOutputLengths` test to check the error
  message
- Expanded `DummyBuildEngine` so you can assert against log messages
- Changed a setting in `.Xamarin.Forms.Android.sln` so the unit test
  project is built
- My VS IDE monkeyed with a few files, and I kept any *good* (or
  relevant) changes: `Xamarin.Forms.UnitTests.csproj`,
  `Xamarin.Forms.Xaml.UnitTests\app.config`, etc.

There were some checks for `%(TargetPath)` being blank in the C# code
of `XamlGTask`. In that case it was using `Path.GetRandomFileName`,
but we can't do this if we are setting up inputs and outputs for
`XamlG`. I presume this is from the designer and/or design-time builds
before `DependsOnTargets="PrepareResourceNames"` was added. I tested
design-time builds in VS on Windows, and `$(TargetPath)` was set. To
be sure we don't break anything here, I exclude inputs to `XamlG` if
`%(TargetPath)` is somehow blank.

See relevant MSBuild code for `%(TargetPath)` here:

0515178090/src/Tasks/Microsoft.Common.CurrentVersion.targets (L2822)

~~ Future changes ~~

CssG needs the exact same setup, as it was patterned after `XamlG`.
This should probably be done in a future PR.

* [msbuild] improved lookup of Xamarin.Forms.targets in integration tests

Context: https://devdiv.visualstudio.com/DevDiv/_build?buildId=1717939
Context: https://devdiv.visualstudio.com/DevDiv/_build?buildId=1718306

It looks like the VSTS builds for release branches are running tests
in a staging directory. This means we can't reliably import
`Xamarin.Forms.targets` as what was working locally in the
Xamarin.Forms source tree.

So to fix this:
- Look for `.nuspec/Xamarin.Forms.targets`, at the default location
  and then using the `BUILD_SOURCESDIRECTORY` environment variable as
  a fallback
- Copy all `*.targets` files to the test directory
- Our `*.csproj` files under test can import the file from there.

We have to copy the targets files here to be sure that MSBuild can
load `Xamarin.Forms.Build.Tasks.dll`, which is also referenced by the
unit tests.

I also made the tests abort earlier if they can't find
`Xamarin.Forms.targets`.
2018-05-25 15:39:17 +01:00
Samantha Houts a6a3b25ade Merge branch '3.0.0' into 3.1.0 2018-05-23 11:26:13 -07:00
Rui Marinho 3fd45e9697 [Nuspec]Remove reference to 23.3.0 support libs (#2802) 2018-05-23 10:27:09 -07:00
Stephane Delcroix dc4dec9df9 Merge branch '3.0.0' into 3.1.0 2018-05-14 10:19:41 +02:00
Stephane Delcroix ba89b8354e [nuspec] update description to add new plats
- fixes #2627
2018-05-09 13:44:42 +02:00
Stephane Delcroix 713ed70cf1 Merge branch '3.0.0' into 3.1.0 2018-05-07 10:02:58 +02:00
Stephane Delcroix 9e54d6dd3b [.targets] Ensure AssignLinkMetadata is executed (#2600)
by setting SynthesizeLinkMetadata to true

- fixes #2583
2018-05-04 11:47:29 -07:00
Rui Marinho b118541351 Merge branch '3.0.0' 2018-05-02 10:15:11 +01:00
E.Z. Hart 6e95a6d51a Use explicit references so VS for Mac doesn't pick up Design files (#2575)
* Use explicit references so VS for Mac doesn't pick up Design files; fixes #2552

* Tabs -> spaces
2018-05-02 09:21:26 +01:00
Jason Smith e0881178d9 Revert "design dlls for all plats (#2493)"
This reverts commit 85e06a7800.
2018-04-30 10:46:05 -07:00
Stephane Delcroix 66175c1b1f Merge branch '3.0.0' 2018-04-26 11:03:15 +02:00
Matt Ward 9e30a33899 Fix .css files not excluded from default None items (#2544)
Fixes VSTS #606364 - CSS files are duplicated in solution pad
2018-04-26 10:54:03 +02:00
Rui Marinho 9a62f8babf Merge branch '3.0.0' 2018-04-19 17:57:28 +01:00
Stephane Delcroix 62f34faef5
[XamlG] depends on PrepareResourceNames (#2477)
make sure TargetPath and ManifestResourceNames metadata are assigned
before running XamlG

- fixes #2395
2018-04-19 10:01:05 +02:00
Stephane Delcroix 85e06a7800
design dlls for all plats (#2493)
- fixes #2474
2018-04-18 15:40:22 +02:00
Jonathan Peppers 65fbdf3167 [msbuild] setup inputs and outputs for XamlC target
Context: https://github.com/jonathanpeppers/XamarinAndroidBuildTimes

After doing a profiling/review of Xamarin.Android project build times, I
noticed that the `XamlC` target was running on every build no matter
what. The project I used was the Forms Master/Detail template from VS
2017 15.6.4.

In my test repo, I was timing the following situations:
1. Completely clean/fresh build
2. Build again, no changes
3. Change C#, build again
4. Change `AndroidResource` XML, build again

In all cases `XamlC` was running, due to the task not having setup
proper inputs and outputs for the MSBuild target. Thinking about it, it
seemed like we could skip `XamlC` as long as the input assembly did not
change, such as case no. 2 or no. 4.

Changes to the `XamlC` target:
- Setup `$(IntermediateOutputPath)$(TargetFileName)` (the assembly) as input
- Setup a `XamlC.stamp` file as an output
- `<Touch />` the `XamlC.stamp` file after running the `XamlCTask`
- Add to the `FileWrites` MSBuild item, so that the `IncrementalClean`
target doesn't delete the stamp file

On my Windows machine, this improved the following build times for cases:
1. same (XamlC should run)
2. 3.685s -> 2.887s
3. same (XamlC should run) (would also be same as XAML changing)
4. 12.126s -> 11.214s

Since this was basically an empty project, I suspect the improvements
would be more drastic for apps with lots of XAML and using `XamlC`.
2018-04-11 10:33:22 -05:00
Rui Marinho 4d9a5bf370
Merge branch '3.0.0' 2018-03-15 17:07:49 +00:00
Rui Marinho 64b7a56b3a
[Nuget] Update nuspec's with msft info (#2108) 2018-03-15 13:54:43 +00:00
E.Z. Hart 599541e3de [UWP] Thumb color and image for Slider (#2065) fixes #1684
* Add demo/test pages for new properties

* Test attributes for new Slider properties

* Implement slider thumb color and thumb image on UWP

* Use nameof for ThumbImage property
2018-03-14 11:02:26 +00:00
Rui Marinho 1233e055d7
[Nuspec] Add .Design dll.s back (#1884) 2018-02-15 11:08:16 +00:00
Stephane Delcroix cf5e8482ed remove $ from our .nuspec (#1881) 2018-02-14 11:42:31 -07:00
Rui Marinho ff40c5b4e1
Add netstandard1.0 support (#1649)
* [Core] Add pcl Xamarin.Forms.Core

* [Core] Add Platform PCL

* [Core] Add Xamarin.Forms.Core PCL

* [Core] Use multi target

*  [Nuget,Core] Add pcl back, multi target netstandard1.0 and netstandard2.0

* [Core] Fix ImageSource for non PCL

* Fix uap

* [UWP] Fix references

* Cleaned up the solution file to remove unused platforms (#1770)

* Try don't build Appx

* [Core]Use netstandard1_0 compile directive

* Don't build UWP and WPF on macOS (#1774)

* [Xaml] Fix compile constant

* [Core] Fix Tuple usage

* [Build] Update provisioning 15.5 sr5

* [Core] Use default compile directive for netstandard1.0

* [Nuget] Add uwp dependency to nuspec

* [Nuspec] Fix speling

* [Core] Add support to FlexLayout on netstandard 1.0

* Try fix test

* cleanup

* [Core] Fix netstandard1.0 usage

* [Core] Remove tuple usage FlexLayout, cleanup
2018-02-08 18:18:56 +00:00
Stephane Delcroix c44728e242
[build] reduce verbosity of build (#1837)
- fixes #1798
2018-02-08 14:31:35 +01:00
Javier Suárez Ruiz 5b5bae6e48 [GTK] Fix Issue 1737: Can't reference GTK Platform (#1772)
* Fixed GTK Platform nuspecs (Map and OpenTK dependencies)

* Fixes in GTK nuspecs

* Fixed problem with GTK nuspecs
2018-02-01 19:49:11 +00:00
Javier Suárez Ruiz 3688cb5f94 [GTK] Fixed bug in the GTK nuspecs (#1746)
* Fixed GTK Platform nuspecs (Map and OpenTK dependencies)

* Fixes in GTK nuspecs
2018-01-30 14:27:15 +00:00
Javier Suárez Ruiz 11bb22a938 Fixed GTK Platform nuspecs (Map and OpenTK dependencies) (#1629) 2018-01-23 10:38:26 +00:00
Javier Suárez Ruiz fa85b658c9 [GTK] Platform and Maps NuGet nuspecs (#1453)
* Added GTK Platform and Maps nuspecs

* Added new GTK nuspecs to the solution

* Changes from PR feedback: Renamed Xamarin.Forms.Platform.GTK.nuspec to Xamarin.Forms.GTK.nuspec and discarded changes in the main sln

* Changed Xamarin.Forms.GTK nuspec identifier

* Updated nuspec (copyright year and Platform id)
2018-01-02 16:29:01 +00:00
Mohamed CHOUCHANE da439af0d4 [WPF] Platform and Maps nuget package (#1445)
* Change OpenTK version to latest stable

* Add Platform and Maps nuspec

* Restore sln
2017-12-21 19:40:07 +00:00
Stephane Delcroix 5ea86a266b
Stylesheets (#1207)
* [*] Support for CSS StyleSheets

 Parsing, loading, and applying of StyleSheets

 see https://github.com/xamarin/Xamarin.Forms/pull/1207#issue-266464280
 for complete description.

* use initial, not none

* fix tests
2017-12-20 10:47:50 +01:00
Stephane Delcroix 3387d17d3d
[Xaml] execute XamlG and XamlC on UWP SAP (#1391) 2017-12-18 11:29:56 +01:00
WonYoung Choi 27ea629c41 Move XF.Build.Tasks to nestandard2.0 (#1370)
Remove net47 project of XF.Build.Tasks. Xamarin.Forms.nupkg provides
Xamarin.Forms.Build.Tasks.dll and dependencies built with netstandard2.0 only.
2017-12-13 14:29:57 +00:00
WonYoung Choi d8f5e7d58d [Tizen] Add Tizen stuff to NuGet packages (#1365) 2017-12-11 15:32:07 +00:00
WonYoung Choi 9383a907c4 [XamlC] Add netstandard2.0 to Xamarin.Forms.Build.Tasks (#1284)
* Add netstandard2.0 to XF.Build.Tasks

* Separate XF.Build.Taks for netstandard 2.0

* Change comparison variable to determine XBuild
2017-12-07 13:58:16 +01:00
Jimmy Garrido 658f321599 [UWP] Update Alert and ActionSheet implementations (#881)
* [UWP] Update Alert and ActionSheet implementations

* Add new xbf file to nuspec

* Fix code after rebase
2017-12-05 16:33:28 +00:00
Stephane Delcroix 1080f04952 [tests] update to cecil 0.10-b7 2017-12-04 11:22:41 +01:00
Stephane Delcroix adbc3958ea [.nuspec] fix typo 2017-12-04 11:15:53 +01:00
Rui Marinho b74d545fc1
[All] Move to netstandard2.0 **Breaking change** (#1306)
* Move to netstandard 2.0

* Fix docs

* Small fixes
2017-11-29 17:37:06 +00:00
Rui Marinho 5a60f17e47
[Win] Remove Windows 8.1 platforms **Breaking change** (#1267)
* [Platforms]Remove WP8.0 and WinRT

* Update submodule

* [UWP] Fix maps UWP

* [UWP] Remove more stuff from old windows platforms

* [Docs] Update docs
2017-11-27 15:14:01 +00:00
Stephane Delcroix f0a2d6ba6f
[Xaml] use [Before|After]Targets to avoid being overriden (#1277) 2017-11-17 09:56:18 +01:00
Stephane Delcroix de255a8b9e [XamlC] XamlResourceIdAttribute (#1167) 2017-10-23 10:56:23 +02:00
Stephane Delcroix d7c6de5a80 Use "correct" file paths for .xaml.g.cs files (#1202)
* putting the chairs on the table

* [XamlG] use correct path for .g.cs files

* [Build] require msbuild

* bump tasks abi
2017-10-19 12:00:47 +02:00
Rui Marinho dff6ecd7b5 [Android] Applinks firebase 42 (#1107)
* Android AppLinks updated packages and refactor to comply with Firebase packages

* made nested classes internal

* removed notimplementedexception and added a Console log when on Failure

* removed Firebase init method. Changed Console for Android's native Exception logging

* formatted code styling with Visual Studio Community 2017 for Mac

* [Android] Update nuspec and gallery

* [Packages] Update android support packages for 25.4.0.2
2017-10-09 13:25:45 -07:00
E.Z. Hart 3aaed1b325 [All] Page embedding (#1124)
* Fix broken SetTextAppearance call when targeting below API 23

* Enable embedding XF apps in Android

* VS didn't save the project file

* Allow retrieving rendered XF VisualElements for use in UWP apps

* Prevent XF from slaughtering the menu bar in embedded scenarios

* ?

* Post-rebase fixups

* Create embedding test project for Android

* Create iOS test bed project

* Attempting to get functional embedded project

* Android and iOS functional testbed projects

* Basic embedding app on UWP

* First pass at handling navigation to Forms page from UWP

* Fleshed out example, added parameter checks, sealed wrapper class

* Create test page and load it from UWP

* Make DisplayAlert/DisplayActionSheet independent of Platform instance on UWP

* Set up test page for alerts/actionsheets on Android

* Move DisplayAlert/ActionSheet code to a helper class so embedded Forms can use it

* VS didn't save my changes

* Add test page for alerts and action sheets

* Get FrameworkElement from renderer

* Page -> ContentPage

* Can now display the webview embedded page

* Example working on iOS

* Repro of crash

* Remove the IStartActivityForResult dependency from FormsWebChromeClient

* Created repro

* Remove need for Forms.Context to create renderers

* Remove Forms.Context dependencies in ScrollViewRenderer

* Remove Forms.Context dependencies in FrameRenderer

* Remove Forms.Context dependencies

* Remove Context/Forms.Context dependencies in Drawable subclasses

* Remove some more Forms.Context dependencies

* CellAdapter no longer dependent on Forms.Context

* Obsolete ToAndroid using Forms.Context

* Remove Forms.Context dependencies in ResourceManager

* Remove need for Forms.Context for SupportsProgress

* Remove Forms.Context dependency for setting titlebar visibility

* Remove Forms.Context dependencies in GetAccentColor

* Some comments about caching

* Remove Forms.Context dependencies for AndroidPlatformServices and ResourceProvider

* Remove Forms.Context dependencies in Maps

* Disabled warnings for Forms.Context in CustomRenderers

* Filter logs so we don't get those annoying "parked" messages

* Filter alerts/actionsheets/activityindicator by context

* Clean up constructor debugging messages

* Remove old TODOs

* Set up test page for Device.Openuri

* Make AndroidDeviceInfo more resilient to multiple activity scenarios

* Use parameter instead of member

* Add missing parameterless constructors for embedded fragment wrappers

* Fix multiple popup subscriptions for embedded context

* Remove UpdateGlobalContext and Page Context attached property

* Obsolete static reference to Context

* Warnings as errors in embedded test bed projects

* Comment cleanup

* Clean up unused code

* Obsolete old constructor for DefaultRenderer

* Make sure embedded fragment wrappers handle disposing the platform

* Revert to old DependencyService registration for ResourceProvider;
use ApplicationContext for ResourceProvider;
Comments for everything happing in Forms.SetupInit

* Remove old TODO

* Make PopupManager take the correct type instead of casting a bunch

* Update docs

* Add missing nuspec entry for FormsEmbeddedPageWrapper

* Post-rebase cleanup

* Update docs

* Disable XF target validation so package restore works

* Restore InputTransparent handling lost in rebase

* Restore parameter lost during rebase

* Finalize the list of subscriptions to avoid 'modified collection' errors

* Avoid double-fetching Context

* Fix "with you package" typo
2017-10-09 10:51:55 -07:00
Jason Smith 7cb7c2a3d8 Add ProjectCapability to targets file (#1164) 2017-09-27 15:56:19 -07:00
Jason Smith 3fb8f6a8ea Fix nuspec file to install DefaultItems.targets in PCL projects (#1163) 2017-09-27 09:57:45 -07:00
Rui Marinho c34cfefea2
Revert "[Nuget]Fix condition to import DefaultItems.targes (#1146)"
This reverts commit 009245626b.
2017-09-26 19:42:43 +01:00
Rui Marinho 4cfdbabb58 [Nuget]Fix condition to import DefaultItems.targes (#1146) 2017-09-19 15:06:31 +01:00