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

11 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 36af029204
Change all null checking expressions to use 'is' and 'is not'. (#18176)
Change all null checking expressions to use 'is null' and 'is not null'
instead of '== null' and '!= null'.

This was mostly done with sed, so code can probably be improved in many
other ways with manual inspection, but that will come over time.

Also add code to the autoformat script to automatically fix these issues in the future.
2023-05-05 17:52:19 +02:00
Rolf Bjarne Kvinge 45ccf885a1
[actions] Autoformat xibuild.csproj (#16059)
Also fix a merge conflict that made autoformatting not work, and make sure to not add any temporary files to the diff.

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2022-09-22 13:07:01 +02:00
Rolf Bjarne Kvinge 2972e1b715
Fix some whitespace issues in various files. (#12399)
* Remove BOM
* Add EOL at end of file.
2021-08-11 10:06:46 +02:00
Rolf Bjarne Kvinge 4586171c4c
[xibuild] Clean up temporary files when done. (#7508) 2019-12-03 14:42:56 +01:00
Rolf Bjarne Kvinge a8fdf6db6e
Implement a different escaping/quoting algorithm for arguments to System.Diagnostics.Process. (#7177)
* Implement a different escaping/quoting algorithm for arguments to System.Diagnostics.Process.

mono changed how quotes should be escaped when passed to
System.Diagnostic.Process, so we need to change accordingly.

The main difference is that single quotes don't have to be escaped anymore.

This solves problems like this:

    System.ComponentModel.Win32Exception : ApplicationName='nuget', CommandLine='restore '/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories/ios-samples/WorkingWithTables/Part 3 - Customizing a Table\'s appearance/3 - CellCustomTable/CellCustomTable.sln' -Verbosity detailed -SolutionDir '/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories/ios-samples/WorkingWithTables/Part 3 - Customizing a Table\'s appearance/3 - CellCustomTable'', CurrentDirectory='/Users/vsts/agent/2.158.0/work/1/s/tests/sampletester/bin/Debug/repositories', Native error= Cannot find the specified file
      at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0029f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/System/System.Diagnostics/Process.cs:778

ref: https://github.com/mono/mono/pull/15047

* Rework process arguments to pass arrays/lists around instead of quoted strings.

And then only convert to a string at the very end when we create the Process
instance.

In the future there will be a ProcessStartInfo.ArgumentList property we can
use to give the original array/list of arguments directly to the BCL so that
we can avoid quoting at all. These changes gets us almost all the way there
already (except that the ArgumentList property isn't available quite yet).

We also have to bump to target framework version v4.7.2 from v4.5 in several
places because of 'Array.Empty<T> ()' which is now used in more places.

* Parse linker flags from LinkWith attributes.

* [sampletester] Bump to v4.7.2 for Array.Empty<T> ().

* Fix typo.

* Rename GetVerbosity -> AddVerbosity.

* Remove unnecessary string interpolation.

* Remove unused variable.

* [mtouch] Simplify code a bit.

* Use implicitly typed arrays.
2019-10-14 16:18:46 +02:00
Jonathan Peppers a51e9f8e88
[xibuild] support for SDK-style projects & Xamarin.Forms test (#6461)
Context: 4ecedac733/src/Shared/BuildEnvironmentHelper.cs (L567-L586)
Context: 1d71d99837/tools/xabuild

When using `xibuild` to build an SDK-style project:

    tools/xibuild/xibuild -- msbuild/tests/MyXamarinFormsApp/MyXamarinFormsAppNS/MyXamarinFormsAppNS.csproj /restore

It was failing with:

    Resolving SDK 'Microsoft.NET.Sdk'...
    Project "msbuild/tests/MyXamarinFormsApp/MyXamarinFormsApp.csproj" is building "msbuild/tests/MyXamarinFormsApp/MyXamarinFormsAppNS/MyXamarinFormsAppNS.csproj" (GetTargetFrameworks target(s)):
    Building with tools version "Current".
    msbuild/tests/MyXamarinFormsApp/MyXamarinFormsAppNS/MyXamarinFormsAppNS.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.

Looking at this code, it looks pretty familiar -- it came from xabuild!

xibuild was currently setting `MSBuildSDKsPath` via a config file:

    <msbuildToolsets default="Current">
      <toolset toolsVersion="Current">
        <property name="MSBuildSDKsPath" value="/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/Current/bin/Sdks" />

Reviewing the source code for MSBuild, they don't even look for this
value via MSBuild properties... They just look for Visual Studio
directories and a `MSBuildSDKsPath` environment variable. We don't have
to use this in Xamarin.Android, because we do things a different way.
There was craziness involved to get both Windows & Mac working.

For this to work on Mac, we can just set `MSBuildSDKsPath` when
starting the new MSBuild process.

I cleaned up how `MSBUILD_EXE_PATH` is set so both of these variables
are just set via `ProcessStartInfo.EnvironmentVariables`.

Now I can fully build a Xamarin.Forms project that references a
netstandard library with `xibuild`:

    $ tools/xibuild/xibuild -- msbuild/tests/MyXamarinFormsApp/MyXamarinFormsApp.csproj /restore
    ...
    Build succeeded.
        0 Warning(s)
        0 Error(s)
    Time Elapsed 00:00:15.83

~~ New Tests ~~

I went ahead and added a new Xamarin.Forms project to test and verify
that it builds. It is the Blank Forms app template from latest VS4Mac.

With the changes to `xibuild`, I was able to build with the in-process
MSBuild APIs.
2019-07-01 12:20:32 -05:00
Ankit Jain 55c4073cb3 [xibuild] Handle "incorrectly" cased msbuild property names (#6202)
msbuild property names are case insensitive. While generating the custom
app.config, in `SetToolsetProperty(..)` we try to update the property if
it already exists. But the name lookup was case sensitive, thus causing
the lookup to fail, resulting in two entries for the same property name
differing only in case. Eg. `MSBuildSDKsPath` vs `MSBuildSdksPath`.

Fixed to ignore case.

Fixes https://github.com/mono/mono/issues/14765 .
2019-06-03 20:47:50 -07:00
Ankit Jain 7dddfb657c [xibuild] Fix incorrect mscorlib.dll being used (#6068)
* [xibuild] Fix incorrect mscorlib.dll being used

The `GuiUnit_NET_4_5` project, when built with `xibuild` uses the wrong `mscorlib.dll`.

From https://github.com/xamarin/xamarin-macios/issues/5760#issuecomment-472457202 :

```
- mscorlib.dll is being used from mono/4.5 and the other system assemblies are from mono/4.5-api
- GuiNet* project is built with xibuild

What is happening here is:

	xibuild sets[1] `SetToolsetProperty ("TargetFrameworkRootPath", FrameworksDirectory + Path.DirectorySeparatorChar);`
	which points to `/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks`.
	This causes $(FrameworkPathOverride) to be set[2] to `/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks/.NETFramework/v4.5`,
	but that doesn't have a mscorlib.dll, so it gets reset[3] to /Library/Frameworks/Mono.framework/Versions/5.22.0/lib/mono/4.5/.

	If we don't set TargetFrameworkRoothPath, then we get `FrameworkPathOverride = /Library/Frameworks/Mono.framework/Versions/5.22.0/lib/mono/4.5-api`,
	causing `_ExplicitReference=/Library/Frameworks/Mono.framework/Versions/5.22.0/lib/mono/4.5-api/mscorlib.dll`(correct one) to be used.
```

Fixes https://github.com/xamarin/xamarin-macios/issues/5760

1. https://github.com/xamarin/xamarin-macios/blob/master/tools/xibuild/Main.cs#L209
2. https://github.com/mono/msbuild/blob/xplat-master/src/Tasks/Microsoft.Common.CurrentVersion.targets#L79
3. https://github.com/mono/msbuild/blob/xplat-master/src/Tasks/Microsoft.Common.CurrentVersion.targets#L84

* Revert "Workaround https://github.com/xamarin/xamarin-macios/issues/5760 in generator csproj"

This reverts commit 9bd927bb7f.

The previous commit for xibuild removes the need for this.
2019-05-17 09:12:05 -07:00
Rolf Bjarne Kvinge 327c0a8ddf
[xibuild] Add support for /verbose, and use it accordingly. (#5224)
* [xibuild] Add support for /verbose, and use it accordingly.

Also stop using xibuild when it's not needed.

* Use the same verbosity for xibuild as we do for xbuild/msbuild.
2019-01-09 07:43:22 +01:00
Rolf Bjarne Kvinge 1af3903f1f
[xibuild] Don't redirect standard input. (#5209)
It's not needed, and it prevents subprocesses from detecting a terminal (and
thus no colors in the output).
2018-12-03 14:52:08 +01:00
Ankit Jain f865694f86 Move tests to use new tool xibuild and thus fix msbuild tests (#5128)
* xibuild: New wrapper tool to run msbuild or managed executables

MSBuild supports fallback paths for projects imported using
`$(MSBuildExtensionsPath)`, but these must be specified explicitly in
the app.config of the main executable. There was a PR to allow use of
properties for this in the app.config, but that was not accepted
upstream.

This is required for being able to:

1. build projects with msbuild against the in-tree XI/XM build output
2. and to run nunit tests against the same.

For this we introduce a new tool, `xibuild`, based on XA's `xabuild`.
This supports the fallback paths to be specified via the environment variable
`MSBuildExtensionsPathFallbackPathsOverride`[1].
It essentially operates in 3 modes:

1. `xibuild -c /path/to/foo.exe`
	Generates /path/to/foo.exe.config with the fallback paths inserted into that.

2. `xibuild -- /v:diag /path/to/project.csproj`
	Runs msbuild with the arguments after `--` with a custom app.config based on
	`MSBuild.dll.config`, with the fallback paths correctly inserted.
	This is in a temporary file and the original config file is not touched.

3. `xibuild -t -- /path/to/managed_tool.exe args`
	Generates `/path/to/managed_tool.exe.config` based on `MSBuild.dll.config` with
	the fallback paths inserted, and runs `managed_tool.exe` with the arguments.
	The default is to overwrite the config file.
	But there is also a switch to merge it with an existing config file.

--
1. Value of the environment variable $MSBuildExtensionsPathFallbackPathsOverride
is prepended to any existing list of search paths in `MSBuild.dll.config`, IOW,
it takes precedence. So, the order of lookup becomes:

  - Value of the property `$(MSBuildExtensionsPath)`
  - Value of the environment variable `$MSBuildExtensionsPathFallbackPathsOverride`
  - /Library/Frameworks/Mono.framework/External/xbuild on macOS

* Integrate use of `xibuild` with the tests

Update all uses of `msbuild` and invocations of tools like nunit that
might depend on using the in-tree builds to use `xibuild`.

* xibuild: Move help descriptions to OptionSet itself.
2018-11-16 14:24:35 -05:00