2021-07-08 20:27:40 +03:00
|
|
|
@echo off
|
|
|
|
|
|
|
|
FOR /F "tokens=1 delims=" %%F IN ('.\build-tools\scripts\vswhere.cmd') DO SET result=%%F
|
|
|
|
2>NUL CALL "%result%\Common7\Tools\VsDevCmd.bat"
|
|
|
|
IF ERRORLEVEL 1 CALL:FAILED_CASE
|
|
|
|
|
|
|
|
2>NUL CALL :%1_CASE
|
|
|
|
IF ERRORLEVEL 1 CALL :DEFAULT_CASE
|
|
|
|
|
|
|
|
:Prepare_CASE
|
dotnet-local & net8: local dotnet first in PATH (#8222)
The .NET 8 `dotnet` command appears to require that `dotnet` be inThe .NET 8 `dotnet` command appears to require that `dotnet` be in
`$PATH`, lest it invoke a *different* `dotnet`. This can result in
weird error messages:
% ~/Developer/src/xamarin/xamarin-android/dotnet-local.sh build *.csproj
…
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : You must install or update .NET to run this application.
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : App: …/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/bincore/csc.dll
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Architecture: x64
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Framework: 'Microsoft.NETCore.App', version '8.0.0-rc.1.23371.3' (x64)
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : .NET location: /usr/local/share/dotnet/
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : The following frameworks were found:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 6.0.16 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.3 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.4 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.5 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.9 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Learn about framework resolution:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet/app-launch-failed
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : To install missing framework, download:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=8.0.0-rc.1.23371.3&arch=x64&rid=osx.13-x64
…
To focus on the weirdness: `dotnet-local.sh` uses the .NET 8 that we
provision into `bin/$(Configuration)/dotnet`, which is .NET 8, while
the error message states that it can only find .NET 6 and 7 from
`/usr/local/share/dotnet`, and *isn't* looking at `bin/*/dotnet`!
.NET 8 Roslyn apparently requires that the "executing" `dotnet` be in
`$PATH`:
% PATH=…/xamarin-android/bin/Debug/dotnet:$PATH \
…/xamarin-android/dotnet-local.sh build *.csproj
# no errors
Update `dotnet-local.sh` and `dotnet-local.cmd` so that `bin/*/dotnet`
is prepended to `$PATH`. Additionally, for readability in
`dotnet-loca.sh`, explicitly export all `DOTNET*` environment
variables so that they don't all need to be on one line.
Update build scripts to use `-nodeReuse:false` instead of `-nr:false`
for readability.
…and some notes about `dotnet-local.cmd`: [`CMD.EXE`][0] environment
variable handling is "baroque".
By default, evironment variables added within a `.cmd` script are
exported to the caller. This is similar to Unixy platforms
["source"][1]ing a script instead of executing a script. To avoid
this behavior, the script should use [SETLOCAL][2]. As we want
`dotnet-local.cmd` to update `%PATH%`, add use of `SETLOCAL` so that
we don't update `%PATH%` on every `dotnet-local.cmd` invocation.
Environment variables are evalated *when a statement is read*,
***not*** when that statement is *executed*. This can make for some
"weird" behavior:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET XA_DOTNET_ROOT=%ROOT%\bin\Release\dotnet
echo XA_DOTNET_ROOT=%XA_DOTNET_ROOT%
)
The above fragment will print `XA_DOTNET_ROOT=` because
`%XA_DOTNET_ROOT%` is evaluated when the entire `IF EXIST …` statment
is read, *not* when the `echo` is executed. This has similar
"wierdness" if we instead attempt to update `PATH`:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET PATH=%ROOT%\bin\Release\dotnet;%PATH%
)
The above invariably fails with weirdness such as:
\NSIS\ was unexpected at this time.
or
\Microsoft was unexpected at this time.
The workaround is one of two options:
1. Consider use "delayed environment variable expansion"; see the
`SET /?` output [^0].
2. Don't Do That™: don't `SET` an environment variable to include
values which are also `SET` in the same statement, and `(…)`
is evaluated as a single statement.
We opt to go with (2), drastically simplifying `dotnet-local.cmd` so
that the `COMMAND` within `IF EXIST filename COMMAND` *only* sets
environment variables which do not reference other environment
variables within the same `COMMAND`
[0]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd
[1]: https://linuxize.com/post/bash-source-command/
[2]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setlocal
[^0]: From `SET /?`:
Delayed environment variable expansion is useful for getting around
the limitations of the current expansion which happens when a line
of text is read, not when it is executed. The following example
demonstrates the problem with immediate variable expansion:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)
would never display the message, since the %VAR% in BOTH IF statements
is substituted when the first IF statement is read, since it logically
includes the body of the IF, which is a compound statement. So the
IF inside the compound statement is really comparing "before" with
"after" which will never be equal. Similarly, the following example
will not work as expected:
set LIST=
for %i in (*) do set LIST=%LIST% %i
echo %LIST%
in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:
for %i in (*) do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows you to use a different
character (the exclamation mark) to expand environment variables at
execution time. …
2023-08-12 13:50:58 +03:00
|
|
|
dotnet msbuild Xamarin.Android.sln -t:Prepare -nodeReuse:false
|
2021-07-08 20:27:40 +03:00
|
|
|
GOTO END_CASE
|
|
|
|
:PrepareExternal_CASE
|
dotnet-local & net8: local dotnet first in PATH (#8222)
The .NET 8 `dotnet` command appears to require that `dotnet` be inThe .NET 8 `dotnet` command appears to require that `dotnet` be in
`$PATH`, lest it invoke a *different* `dotnet`. This can result in
weird error messages:
% ~/Developer/src/xamarin/xamarin-android/dotnet-local.sh build *.csproj
…
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : You must install or update .NET to run this application.
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : App: …/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/bincore/csc.dll
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Architecture: x64
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Framework: 'Microsoft.NETCore.App', version '8.0.0-rc.1.23371.3' (x64)
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : .NET location: /usr/local/share/dotnet/
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : The following frameworks were found:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 6.0.16 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.3 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.4 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.5 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.9 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Learn about framework resolution:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet/app-launch-failed
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : To install missing framework, download:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=8.0.0-rc.1.23371.3&arch=x64&rid=osx.13-x64
…
To focus on the weirdness: `dotnet-local.sh` uses the .NET 8 that we
provision into `bin/$(Configuration)/dotnet`, which is .NET 8, while
the error message states that it can only find .NET 6 and 7 from
`/usr/local/share/dotnet`, and *isn't* looking at `bin/*/dotnet`!
.NET 8 Roslyn apparently requires that the "executing" `dotnet` be in
`$PATH`:
% PATH=…/xamarin-android/bin/Debug/dotnet:$PATH \
…/xamarin-android/dotnet-local.sh build *.csproj
# no errors
Update `dotnet-local.sh` and `dotnet-local.cmd` so that `bin/*/dotnet`
is prepended to `$PATH`. Additionally, for readability in
`dotnet-loca.sh`, explicitly export all `DOTNET*` environment
variables so that they don't all need to be on one line.
Update build scripts to use `-nodeReuse:false` instead of `-nr:false`
for readability.
…and some notes about `dotnet-local.cmd`: [`CMD.EXE`][0] environment
variable handling is "baroque".
By default, evironment variables added within a `.cmd` script are
exported to the caller. This is similar to Unixy platforms
["source"][1]ing a script instead of executing a script. To avoid
this behavior, the script should use [SETLOCAL][2]. As we want
`dotnet-local.cmd` to update `%PATH%`, add use of `SETLOCAL` so that
we don't update `%PATH%` on every `dotnet-local.cmd` invocation.
Environment variables are evalated *when a statement is read*,
***not*** when that statement is *executed*. This can make for some
"weird" behavior:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET XA_DOTNET_ROOT=%ROOT%\bin\Release\dotnet
echo XA_DOTNET_ROOT=%XA_DOTNET_ROOT%
)
The above fragment will print `XA_DOTNET_ROOT=` because
`%XA_DOTNET_ROOT%` is evaluated when the entire `IF EXIST …` statment
is read, *not* when the `echo` is executed. This has similar
"wierdness" if we instead attempt to update `PATH`:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET PATH=%ROOT%\bin\Release\dotnet;%PATH%
)
The above invariably fails with weirdness such as:
\NSIS\ was unexpected at this time.
or
\Microsoft was unexpected at this time.
The workaround is one of two options:
1. Consider use "delayed environment variable expansion"; see the
`SET /?` output [^0].
2. Don't Do That™: don't `SET` an environment variable to include
values which are also `SET` in the same statement, and `(…)`
is evaluated as a single statement.
We opt to go with (2), drastically simplifying `dotnet-local.cmd` so
that the `COMMAND` within `IF EXIST filename COMMAND` *only* sets
environment variables which do not reference other environment
variables within the same `COMMAND`
[0]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd
[1]: https://linuxize.com/post/bash-source-command/
[2]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setlocal
[^0]: From `SET /?`:
Delayed environment variable expansion is useful for getting around
the limitations of the current expansion which happens when a line
of text is read, not when it is executed. The following example
demonstrates the problem with immediate variable expansion:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)
would never display the message, since the %VAR% in BOTH IF statements
is substituted when the first IF statement is read, since it logically
includes the body of the IF, which is a compound statement. So the
IF inside the compound statement is really comparing "before" with
"after" which will never be equal. Similarly, the following example
will not work as expected:
set LIST=
for %i in (*) do set LIST=%LIST% %i
echo %LIST%
in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:
for %i in (*) do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows you to use a different
character (the exclamation mark) to expand environment variables at
execution time. …
2023-08-12 13:50:58 +03:00
|
|
|
dotnet build Xamarin.Android.sln -t:PrepareExternal -nodeReuse:false
|
2021-07-08 20:27:40 +03:00
|
|
|
GOTO END_CASE
|
|
|
|
:Build_CASE
|
dotnet-local & net8: local dotnet first in PATH (#8222)
The .NET 8 `dotnet` command appears to require that `dotnet` be inThe .NET 8 `dotnet` command appears to require that `dotnet` be in
`$PATH`, lest it invoke a *different* `dotnet`. This can result in
weird error messages:
% ~/Developer/src/xamarin/xamarin-android/dotnet-local.sh build *.csproj
…
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : You must install or update .NET to run this application.
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : App: …/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/bincore/csc.dll
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Architecture: x64
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Framework: 'Microsoft.NETCore.App', version '8.0.0-rc.1.23371.3' (x64)
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : .NET location: /usr/local/share/dotnet/
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : The following frameworks were found:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 6.0.16 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.3 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.4 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.5 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.9 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Learn about framework resolution:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet/app-launch-failed
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : To install missing framework, download:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=8.0.0-rc.1.23371.3&arch=x64&rid=osx.13-x64
…
To focus on the weirdness: `dotnet-local.sh` uses the .NET 8 that we
provision into `bin/$(Configuration)/dotnet`, which is .NET 8, while
the error message states that it can only find .NET 6 and 7 from
`/usr/local/share/dotnet`, and *isn't* looking at `bin/*/dotnet`!
.NET 8 Roslyn apparently requires that the "executing" `dotnet` be in
`$PATH`:
% PATH=…/xamarin-android/bin/Debug/dotnet:$PATH \
…/xamarin-android/dotnet-local.sh build *.csproj
# no errors
Update `dotnet-local.sh` and `dotnet-local.cmd` so that `bin/*/dotnet`
is prepended to `$PATH`. Additionally, for readability in
`dotnet-loca.sh`, explicitly export all `DOTNET*` environment
variables so that they don't all need to be on one line.
Update build scripts to use `-nodeReuse:false` instead of `-nr:false`
for readability.
…and some notes about `dotnet-local.cmd`: [`CMD.EXE`][0] environment
variable handling is "baroque".
By default, evironment variables added within a `.cmd` script are
exported to the caller. This is similar to Unixy platforms
["source"][1]ing a script instead of executing a script. To avoid
this behavior, the script should use [SETLOCAL][2]. As we want
`dotnet-local.cmd` to update `%PATH%`, add use of `SETLOCAL` so that
we don't update `%PATH%` on every `dotnet-local.cmd` invocation.
Environment variables are evalated *when a statement is read*,
***not*** when that statement is *executed*. This can make for some
"weird" behavior:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET XA_DOTNET_ROOT=%ROOT%\bin\Release\dotnet
echo XA_DOTNET_ROOT=%XA_DOTNET_ROOT%
)
The above fragment will print `XA_DOTNET_ROOT=` because
`%XA_DOTNET_ROOT%` is evaluated when the entire `IF EXIST …` statment
is read, *not* when the `echo` is executed. This has similar
"wierdness" if we instead attempt to update `PATH`:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET PATH=%ROOT%\bin\Release\dotnet;%PATH%
)
The above invariably fails with weirdness such as:
\NSIS\ was unexpected at this time.
or
\Microsoft was unexpected at this time.
The workaround is one of two options:
1. Consider use "delayed environment variable expansion"; see the
`SET /?` output [^0].
2. Don't Do That™: don't `SET` an environment variable to include
values which are also `SET` in the same statement, and `(…)`
is evaluated as a single statement.
We opt to go with (2), drastically simplifying `dotnet-local.cmd` so
that the `COMMAND` within `IF EXIST filename COMMAND` *only* sets
environment variables which do not reference other environment
variables within the same `COMMAND`
[0]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd
[1]: https://linuxize.com/post/bash-source-command/
[2]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setlocal
[^0]: From `SET /?`:
Delayed environment variable expansion is useful for getting around
the limitations of the current expansion which happens when a line
of text is read, not when it is executed. The following example
demonstrates the problem with immediate variable expansion:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)
would never display the message, since the %VAR% in BOTH IF statements
is substituted when the first IF statement is read, since it logically
includes the body of the IF, which is a compound statement. So the
IF inside the compound statement is really comparing "before" with
"after" which will never be equal. Similarly, the following example
will not work as expected:
set LIST=
for %i in (*) do set LIST=%LIST% %i
echo %LIST%
in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:
for %i in (*) do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows you to use a different
character (the exclamation mark) to expand environment variables at
execution time. …
2023-08-12 13:50:58 +03:00
|
|
|
dotnet-local.cmd build Xamarin.Android.sln -nodeReuse:false
|
2021-07-08 20:27:40 +03:00
|
|
|
GOTO END_CASE
|
|
|
|
:Pack_CASE
|
dotnet-local & net8: local dotnet first in PATH (#8222)
The .NET 8 `dotnet` command appears to require that `dotnet` be inThe .NET 8 `dotnet` command appears to require that `dotnet` be in
`$PATH`, lest it invoke a *different* `dotnet`. This can result in
weird error messages:
% ~/Developer/src/xamarin/xamarin-android/dotnet-local.sh build *.csproj
…
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : You must install or update .NET to run this application.
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : App: …/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/bincore/csc.dll
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Architecture: x64
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Framework: 'Microsoft.NETCore.App', version '8.0.0-rc.1.23371.3' (x64)
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : .NET location: /usr/local/share/dotnet/
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : The following frameworks were found:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 6.0.16 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.3 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.4 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.5 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.9 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Learn about framework resolution:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet/app-launch-failed
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : To install missing framework, download:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=8.0.0-rc.1.23371.3&arch=x64&rid=osx.13-x64
…
To focus on the weirdness: `dotnet-local.sh` uses the .NET 8 that we
provision into `bin/$(Configuration)/dotnet`, which is .NET 8, while
the error message states that it can only find .NET 6 and 7 from
`/usr/local/share/dotnet`, and *isn't* looking at `bin/*/dotnet`!
.NET 8 Roslyn apparently requires that the "executing" `dotnet` be in
`$PATH`:
% PATH=…/xamarin-android/bin/Debug/dotnet:$PATH \
…/xamarin-android/dotnet-local.sh build *.csproj
# no errors
Update `dotnet-local.sh` and `dotnet-local.cmd` so that `bin/*/dotnet`
is prepended to `$PATH`. Additionally, for readability in
`dotnet-loca.sh`, explicitly export all `DOTNET*` environment
variables so that they don't all need to be on one line.
Update build scripts to use `-nodeReuse:false` instead of `-nr:false`
for readability.
…and some notes about `dotnet-local.cmd`: [`CMD.EXE`][0] environment
variable handling is "baroque".
By default, evironment variables added within a `.cmd` script are
exported to the caller. This is similar to Unixy platforms
["source"][1]ing a script instead of executing a script. To avoid
this behavior, the script should use [SETLOCAL][2]. As we want
`dotnet-local.cmd` to update `%PATH%`, add use of `SETLOCAL` so that
we don't update `%PATH%` on every `dotnet-local.cmd` invocation.
Environment variables are evalated *when a statement is read*,
***not*** when that statement is *executed*. This can make for some
"weird" behavior:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET XA_DOTNET_ROOT=%ROOT%\bin\Release\dotnet
echo XA_DOTNET_ROOT=%XA_DOTNET_ROOT%
)
The above fragment will print `XA_DOTNET_ROOT=` because
`%XA_DOTNET_ROOT%` is evaluated when the entire `IF EXIST …` statment
is read, *not* when the `echo` is executed. This has similar
"wierdness" if we instead attempt to update `PATH`:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET PATH=%ROOT%\bin\Release\dotnet;%PATH%
)
The above invariably fails with weirdness such as:
\NSIS\ was unexpected at this time.
or
\Microsoft was unexpected at this time.
The workaround is one of two options:
1. Consider use "delayed environment variable expansion"; see the
`SET /?` output [^0].
2. Don't Do That™: don't `SET` an environment variable to include
values which are also `SET` in the same statement, and `(…)`
is evaluated as a single statement.
We opt to go with (2), drastically simplifying `dotnet-local.cmd` so
that the `COMMAND` within `IF EXIST filename COMMAND` *only* sets
environment variables which do not reference other environment
variables within the same `COMMAND`
[0]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd
[1]: https://linuxize.com/post/bash-source-command/
[2]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setlocal
[^0]: From `SET /?`:
Delayed environment variable expansion is useful for getting around
the limitations of the current expansion which happens when a line
of text is read, not when it is executed. The following example
demonstrates the problem with immediate variable expansion:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)
would never display the message, since the %VAR% in BOTH IF statements
is substituted when the first IF statement is read, since it logically
includes the body of the IF, which is a compound statement. So the
IF inside the compound statement is really comparing "before" with
"after" which will never be equal. Similarly, the following example
will not work as expected:
set LIST=
for %i in (*) do set LIST=%LIST% %i
echo %LIST%
in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:
for %i in (*) do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows you to use a different
character (the exclamation mark) to expand environment variables at
execution time. …
2023-08-12 13:50:58 +03:00
|
|
|
dotnet-local.cmd build Xamarin.Android.sln -t:PackDotNet -nodeReuse:false
|
2021-07-08 20:27:40 +03:00
|
|
|
GOTO END_CASE
|
|
|
|
:DEFAULT_CASE
|
dotnet-local & net8: local dotnet first in PATH (#8222)
The .NET 8 `dotnet` command appears to require that `dotnet` be inThe .NET 8 `dotnet` command appears to require that `dotnet` be in
`$PATH`, lest it invoke a *different* `dotnet`. This can result in
weird error messages:
% ~/Developer/src/xamarin/xamarin-android/dotnet-local.sh build *.csproj
…
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : You must install or update .NET to run this application.
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : App: …/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/bincore/csc.dll
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Architecture: x64
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Framework: 'Microsoft.NETCore.App', version '8.0.0-rc.1.23371.3' (x64)
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : .NET location: /usr/local/share/dotnet/
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : The following frameworks were found:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 6.0.16 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.3 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.4 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.5 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.9 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Learn about framework resolution:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet/app-launch-failed
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error :
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : To install missing framework, download:
…/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=8.0.0-rc.1.23371.3&arch=x64&rid=osx.13-x64
…
To focus on the weirdness: `dotnet-local.sh` uses the .NET 8 that we
provision into `bin/$(Configuration)/dotnet`, which is .NET 8, while
the error message states that it can only find .NET 6 and 7 from
`/usr/local/share/dotnet`, and *isn't* looking at `bin/*/dotnet`!
.NET 8 Roslyn apparently requires that the "executing" `dotnet` be in
`$PATH`:
% PATH=…/xamarin-android/bin/Debug/dotnet:$PATH \
…/xamarin-android/dotnet-local.sh build *.csproj
# no errors
Update `dotnet-local.sh` and `dotnet-local.cmd` so that `bin/*/dotnet`
is prepended to `$PATH`. Additionally, for readability in
`dotnet-loca.sh`, explicitly export all `DOTNET*` environment
variables so that they don't all need to be on one line.
Update build scripts to use `-nodeReuse:false` instead of `-nr:false`
for readability.
…and some notes about `dotnet-local.cmd`: [`CMD.EXE`][0] environment
variable handling is "baroque".
By default, evironment variables added within a `.cmd` script are
exported to the caller. This is similar to Unixy platforms
["source"][1]ing a script instead of executing a script. To avoid
this behavior, the script should use [SETLOCAL][2]. As we want
`dotnet-local.cmd` to update `%PATH%`, add use of `SETLOCAL` so that
we don't update `%PATH%` on every `dotnet-local.cmd` invocation.
Environment variables are evalated *when a statement is read*,
***not*** when that statement is *executed*. This can make for some
"weird" behavior:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET XA_DOTNET_ROOT=%ROOT%\bin\Release\dotnet
echo XA_DOTNET_ROOT=%XA_DOTNET_ROOT%
)
The above fragment will print `XA_DOTNET_ROOT=` because
`%XA_DOTNET_ROOT%` is evaluated when the entire `IF EXIST …` statment
is read, *not* when the `echo` is executed. This has similar
"wierdness" if we instead attempt to update `PATH`:
IF EXIST "%ROOT%\bin\Release\dotnet\dotnet.exe" (
SET PATH=%ROOT%\bin\Release\dotnet;%PATH%
)
The above invariably fails with weirdness such as:
\NSIS\ was unexpected at this time.
or
\Microsoft was unexpected at this time.
The workaround is one of two options:
1. Consider use "delayed environment variable expansion"; see the
`SET /?` output [^0].
2. Don't Do That™: don't `SET` an environment variable to include
values which are also `SET` in the same statement, and `(…)`
is evaluated as a single statement.
We opt to go with (2), drastically simplifying `dotnet-local.cmd` so
that the `COMMAND` within `IF EXIST filename COMMAND` *only* sets
environment variables which do not reference other environment
variables within the same `COMMAND`
[0]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd
[1]: https://linuxize.com/post/bash-source-command/
[2]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setlocal
[^0]: From `SET /?`:
Delayed environment variable expansion is useful for getting around
the limitations of the current expansion which happens when a line
of text is read, not when it is executed. The following example
demonstrates the problem with immediate variable expansion:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)
would never display the message, since the %VAR% in BOTH IF statements
is substituted when the first IF statement is read, since it logically
includes the body of the IF, which is a compound statement. So the
IF inside the compound statement is really comparing "before" with
"after" which will never be equal. Similarly, the following example
will not work as expected:
set LIST=
for %i in (*) do set LIST=%LIST% %i
echo %LIST%
in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:
for %i in (*) do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows you to use a different
character (the exclamation mark) to expand environment variables at
execution time. …
2023-08-12 13:50:58 +03:00
|
|
|
dotnet msbuild Xamarin.Android.sln -t:Prepare -nodeReuse:false
|
|
|
|
dotnet-local.cmd build Xamarin.Android.sln -nodeReuse:false
|
|
|
|
dotnet-local.cmd build Xamarin.Android.sln -t:PackDotNet -nodeReuse:false
|
2021-07-08 20:27:40 +03:00
|
|
|
GOTO END_CASE
|
|
|
|
:FAILED_CASE
|
|
|
|
echo "Failed to find an instance of Visual Studio. Please check it is correctly installed."
|
|
|
|
GOTO END_CASE
|
|
|
|
:END_CASE
|
2023-08-14 22:48:43 +03:00
|
|
|
GOTO :EOF
|