Skip to content

Commit

Permalink
[dotnet] Implement a workaround for .NET's lack of extensibility for …
Browse files Browse the repository at this point in the history
…'dotnet run'.

.NET doesn't support executing other targets/tasks when doing "dotnet run".
However, we need to (like we do for our current "Run" target), so implement a
rather simplistic/hacky workaround by making "dotnet run" just do "dotnet
build /t:Run".

It doesn't support everything that "dotnet run" does (for instance it doesn't
support the /no-build flag), but it should work for most use cases.

Ref: dotnet/sdk#18436
  • Loading branch information
rolfbjarne committed Aug 17, 2021
1 parent 454831f commit 19789e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dotnet/Microsoft.iOS.Sdk/targets/Microsoft.iOS.Sdk.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Xamarin.Shared.Sdk.targets" />

<!--
There's no way to execute a task (for instance to calculate the arguments to mlaunch) in "dotnet run",
so we rely on the 'Run' target instead. Quite ugly, but it seems to work, even though it won't support
"dotnet run" flags such as /no-build. OTOH we try to support /configuration and /runtime.
Ref: https:/dotnet/sdk/issues/18436
-->
<PropertyGroup>
<RunCommand>$(NetCoreRoot)/dotnet</RunCommand>
<RunArguments>build "$(MSBuildProjectFullPath)" /t:Run /p:RuntimeIdentifier=$(RuntimeIdentifier) /p:Configuration=$(Configuration)</RunArguments>
</PropertyGroup>
</Project>
11 changes: 11 additions & 0 deletions dotnet/Microsoft.tvOS.Sdk/targets/Microsoft.tvOS.Sdk.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Xamarin.Shared.Sdk.targets" />

<!--
There's no way to execute a task (for instance to calculate the arguments to mlaunch) in "dotnet run",
so we rely on the 'Run' target instead. Quite ugly, but it seems to work, even though it won't support
"dotnet run" flags such as /no-build. OTOH we try to support /configuration and /runtime.
Ref: https:/dotnet/sdk/issues/18436
-->
<PropertyGroup>
<RunCommand>$(NetCoreRoot)/dotnet</RunCommand>
<RunArguments>build "$(MSBuildProjectFullPath)" /t:Run /p:RuntimeIdentifier=$(RuntimeIdentifier) /p:Configuration=$(Configuration)</RunArguments>
</PropertyGroup>
</Project>

0 comments on commit 19789e3

Please sign in to comment.