Skip to content

.Net core x86 support#2161

Merged
singhsarab merged 3 commits intomicrosoft:masterfrom
singhsarab:x86NetCoreSupport
Sep 11, 2019
Merged

.Net core x86 support#2161
singhsarab merged 3 commits intomicrosoft:masterfrom
singhsarab:x86NetCoreSupport

Conversation

@singhsarab
Copy link
Copy Markdown
Contributor

@singhsarab singhsarab commented Sep 10, 2019

Description

Using the apphost sdk feature to enable the x86 support for .Net core projects.

Related issue

#1128
#2101

@singhsarab
Copy link
Copy Markdown
Contributor Author

Will add acceptance tests for this.

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(Platform)' == 'x86'">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check with $(OS) property to selectively drop these exe's, this will also help while fetching testhost path in runtime provider.

<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)x64\testhost.dll">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSBuildThisFileDirectory [](start = 24, length = 24)

check for errors/warning because this will try to replace anycpu "testhost.dll"

@microsoft microsoft deleted a comment from mayankbansal018 Sep 11, 2019
Copy link
Copy Markdown
Contributor

@mayankbansal018 mayankbansal018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@singhsarab singhsarab merged commit 96bb81e into microsoft:master Sep 11, 2019
@singhsarab
Copy link
Copy Markdown
Contributor Author

@ViktorHofer You might be interested in taking a look at this.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(Platform)' == 'x86' AND '$(OS)' == 'Windows_NT'">
<Content Include="$(MSBuildThisFileDirectory)x86\testhost.x86.exe">
Copy link
Copy Markdown
Member

@ViktorHofer ViktorHofer Sep 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the testhost.dll copied over into the output directory today, without this change? Does this really need to be copied to the output directory when on .NET Core with deps.json support? Can't it just be invoked from the nuget package cache and copied over only when doing a dotnet publish? That should be the default afaik.

Copy link
Copy Markdown
Contributor Author

@singhsarab singhsarab Sep 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, testhost.dll today does not get copied, and we rely on the deps file for references.

We can't keep new binaries in the lib folder, they need to go into the build folder, reason being all the things in lib get referenced and better be AnyCPU.

Now I can device a logic to find the testhost.dll from the nuget cache and then walk out to build folder to find the appropriate executable, but then this won't work for dotnet publish. Is there a way to conditionally copy only during publish ?
Also we felt keeping this logic consistent made sense.

Do you see any issues in the current approach ?

Copy link
Copy Markdown
Member

@ViktorHofer ViktorHofer Sep 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't keep new binaries in the lib folder, they need to go into the build folder, reason being all the things in lib get referenced and better be AnyCPU.

Why not put it into tools? We do the same for some other tools. Assembly there won't be referenced by the compiler.

Do you see any issues in the current approach ?

Mainly that the assembly will always be copied over. If there's a way to avoid that I would definitely prefer that.

Now I can device a logic to find the testhost.dll from the nuget cache and then walk out to build folder to find the appropriate executable, but then this won't work for dotnet publish. Is there a way to conditionally copy only during publish ?

Yes you can hook into the ResolvedFileToPublish item:

<ItemGroup>
    <ResolvedFileToPublish Include="C:\Users\vihofer\.nuget\packages\microsoft.testplatform.testhost\16.2.0\lib\uap10.0\testhost.dll" RelativePath="testhost.x86.dll" CopyToPublishDirectory="PreserveNewest" />
  </ItemGroup>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's up to you :)

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(Platform)' == 'x86' AND '$(OS)' == 'Windows_NT'">
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is testhost.x86.exe copied only in case if Platform set to x86? dotnet publish prepare output that can be executed with dotnet vstest, which will get Platfrom parameter at runtime. If both testhost will be in output folder, it will be able to run test with appropriate bitness. Should separate bug for it be created?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thx.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is last thing to allow resolve #1128, so I've mentioned it there with new comment instead of creating new issue.

@iskiselev iskiselev mentioned this pull request Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants