Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Fixes: #2548
Fixes: http://work.devdiv.io/753650

In the case of the Android designer, a SetupDependenciesForDesigner
target is run as a way to "build enough" things for the designer to
work.

The problem is if a <ProjectReference/> hasn't built yet, the
_ResolveAssemblies target can fail:

"HelloForms.Android.csproj" (SetupDependenciesForDesigner target) (1:7) ->
(_ResolveAssemblies target) ->
Xamarin.Android.Common.targets(1898,2): error : Exception while loading assemblies: System.InvalidOperationException: Failed to load assembly HelloForms\bin\Debug\netstandard2.0\HelloForms.dll
Xamarin.Android.Common.targets(1898,2): error :    at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)

In this case, I ran:

msbuild .\HelloForms\HelloForms.Android\HelloForms.Android.csproj /t:SetupDependenciesForDesigner /p:DesignTimeBuild=true /p:AndroidUseManagedDesignTimeResourceGenerator=false /restore /bl

From a fresh checkout of this sample:

https://github.com/jonathanpeppers/HelloWorld/

To fix this problem, we can add an Exists check in the Condition
for assemblies passed into the <ResolveAssemblies/> MSBuild task. I
don't think this will have any negative consequences, since we are
already doing a check for Exists ('$(OutDir)$(TargetFileName)').

I also setup a new test that emulates what happens with
SetupDependenciesForDesigner. This should also help us make sure we
aren't breaking the designer in this repo.

Downstream in monodroid, we should also make sure the designer tests
we have there are using a <ProjectReference/>.

…g assemblies

Fixes: dotnet#2548
Fixes: http://work.devdiv.io/753650

In the case of the Android designer, a `SetupDependenciesForDesigner`
target is run as a way to "build enough" things for the designer to
work.

The problem is if a `<ProjectReference/>` hasn't built yet, the
`_ResolveAssemblies` target can fail:

    "HelloForms.Android.csproj" (SetupDependenciesForDesigner target) (1:7) ->
    (_ResolveAssemblies target) ->
    Xamarin.Android.Common.targets(1898,2): error : Exception while loading assemblies: System.InvalidOperationException: Failed to load assembly HelloForms\bin\Debug\netstandard2.0\HelloForms.dll
    Xamarin.Android.Common.targets(1898,2): error :    at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)

In this case, I ran:

    msbuild .\HelloForms\HelloForms.Android\HelloForms.Android.csproj /t:SetupDependenciesForDesigner /p:DesignTimeBuild=true /p:AndroidUseManagedDesignTimeResourceGenerator=false /restore /bl

From a fresh checkout of this sample:

https://github.com/jonathanpeppers/HelloWorld/

To fix this problem, we can add an `Exists` check in the `Condition`
for assemblies passed into the `<ResolveAssemblies/>` MSBuild task. I
don't think this will have any negative consequences, since we are
already doing a check for `Exists ('$(OutDir)$(TargetFileName)')`.

I also setup a new test that emulates what happens with
`SetupDependenciesForDesigner`. This should also help us make sure we
aren't breaking the designer in this repo.

Downstream in monodroid, we should also make sure the designer tests
we have there are using a `<ProjectReference/>`.
@jonathanpeppers
Copy link
Member Author

/cc @garuma @alanmcgovern

@dellis1972 dellis1972 merged commit 974cf7d into dotnet:master Jan 16, 2019
jonpryor pushed a commit that referenced this pull request Jan 17, 2019
…g assemblies (#2622)

Fixes: #2548
Fixes: http://work.devdiv.io/753650

In the case of the Android designer, a `SetupDependenciesForDesigner`
target is run as a way to "build enough" things for the designer to
work.

The problem is if a `<ProjectReference/>` hasn't built yet, the
`_ResolveAssemblies` target can fail:

    "HelloForms.Android.csproj" (SetupDependenciesForDesigner target) (1:7) ->
    (_ResolveAssemblies target) ->
    Xamarin.Android.Common.targets(1898,2): error : Exception while loading assemblies: System.InvalidOperationException: Failed to load assembly HelloForms\bin\Debug\netstandard2.0\HelloForms.dll
    Xamarin.Android.Common.targets(1898,2): error :    at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)

In this case, I ran:

    msbuild .\HelloForms\HelloForms.Android\HelloForms.Android.csproj /t:SetupDependenciesForDesigner /p:DesignTimeBuild=true /p:AndroidUseManagedDesignTimeResourceGenerator=false /restore /bl

From a fresh checkout of this sample:

https://github.com/jonathanpeppers/HelloWorld/

To fix this problem, we can add an `Exists` check in the `Condition`
for assemblies passed into the `<ResolveAssemblies/>` MSBuild task. I
don't think this will have any negative consequences, since we are
already doing a check for `Exists ('$(OutDir)$(TargetFileName)')`.

I also setup a new test that emulates what happens with
`SetupDependenciesForDesigner`. This should also help us make sure we
aren't breaking the designer in this repo.

Downstream in monodroid, we should also make sure the designer tests
we have there are using a `<ProjectReference/>`.
garuma pushed a commit that referenced this pull request Jan 25, 2019
…g assemblies (#2622)

Fixes: #2548
Fixes: http://work.devdiv.io/753650

In the case of the Android designer, a `SetupDependenciesForDesigner`
target is run as a way to "build enough" things for the designer to
work.

The problem is if a `<ProjectReference/>` hasn't built yet, the
`_ResolveAssemblies` target can fail:

    "HelloForms.Android.csproj" (SetupDependenciesForDesigner target) (1:7) ->
    (_ResolveAssemblies target) ->
    Xamarin.Android.Common.targets(1898,2): error : Exception while loading assemblies: System.InvalidOperationException: Failed to load assembly HelloForms\bin\Debug\netstandard2.0\HelloForms.dll
    Xamarin.Android.Common.targets(1898,2): error :    at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)

In this case, I ran:

    msbuild .\HelloForms\HelloForms.Android\HelloForms.Android.csproj /t:SetupDependenciesForDesigner /p:DesignTimeBuild=true /p:AndroidUseManagedDesignTimeResourceGenerator=false /restore /bl

From a fresh checkout of this sample:

https://github.com/jonathanpeppers/HelloWorld/

To fix this problem, we can add an `Exists` check in the `Condition`
for assemblies passed into the `<ResolveAssemblies/>` MSBuild task. I
don't think this will have any negative consequences, since we are
already doing a check for `Exists ('$(OutDir)$(TargetFileName)')`.

I also setup a new test that emulates what happens with
`SetupDependenciesForDesigner`. This should also help us make sure we
aren't breaking the designer in this repo.

Downstream in monodroid, we should also make sure the designer tests
we have there are using a `<ProjectReference/>`.
@jonathanpeppers jonathanpeppers deleted the setupdependenciesfordesigner branch January 28, 2019 18:05
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[spec] MSBuild target changes to support Android Designer

2 participants