Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let DafnyRuntime target more frameworks #2604

Merged
merged 12 commits into from
Sep 2, 2022
Merged

Conversation

atomb
Copy link
Member

@atomb atomb commented Aug 17, 2022

Allow the DafnyRuntime package to work with netstandard2.0 and net462, as well as the previous net6.0. This should make Dafny target code that links with a pre-built DafnyRuntime.dll more portable.

Fixes #2481

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@atomb atomb marked this pull request as ready for review August 17, 2022 17:32
Comment on lines 50 to 51
dotnet build -f net462 Source/DafnyRuntime/DafnyRuntime.csproj
dotnet build -f netstandard2.0 Source/DafnyRuntime/DafnyRuntime.csproj
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this generate 3 runtimes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, one for each of those frameworks, so that folks downloading from NuGet can get the one that works for them. My understanding is that this is the best way to make .NET libraries available for many versions, but I'd love to hear about a better way if there is one.

@atomb atomb requested a review from fabiomadge August 17, 2022 19:10
run: dotnet build Source/Dafny.sln
run: |
dotnet build Source/Dafny.sln
dotnet build -f net462 Source/DafnyRuntime/DafnyRuntime.csproj
Copy link
Member

@keyboardDrummer keyboardDrummer Aug 19, 2022

Choose a reason for hiding this comment

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

Are these useful frameworks to target? Who would consume a netstandard2.0 or a net462 library? How about only targeting net5.0 or net3.1 depending on how far back we want to support?

Copy link
Member Author

@atomb atomb Aug 19, 2022

Choose a reason for hiding this comment

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

This was partly informed by the dependencies here with the adjustment that the current runtime doesn't build with net452 but does work as far back as netstandard2.0. I also took guidance from here.

Copy link
Member

@keyboardDrummer keyboardDrummer Aug 22, 2022

Choose a reason for hiding this comment

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

If Standard allows sharing code with Framework and Core, then why would you build for Standard AND something else?

From the linked docs:

Most widely used libraries will multi-target for both .NET Standard 2.0 and .NET 5+. Supporting .NET Standard 2.0 gives you the most reach, while supporting .NET 5+ ensures you can leverage the latest platform features for customers that are already on .NET 5+.

I think targeting just standard would be enough for us.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm. Re-reading that page, I think you may be right. It seems as though if we built for netstandard2.1 we might also need a separate build to support Framework (e.g., net462), but if we build for netstandard2.0 we don't need that?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, looks like it. But pff, that 2.1 vs 2.0 matters so much is confusing!

It seems that netstandard2.0 is sufficient
@atomb atomb requested a review from keyboardDrummer August 22, 2022 17:29
@atomb atomb enabled auto-merge (squash) September 1, 2022 17:13
@atomb atomb merged commit 709ed5a into dafny-lang:master Sep 2, 2022
keyboardDrummer added a commit to keyboardDrummer/dafny that referenced this pull request Sep 8, 2022
keyboardDrummer added a commit that referenced this pull request Sep 8, 2022
This reverts commit 709ed5a. (PR #2604)

Resolving the issue that Rider no longer builds:

```
Build started 09/08/2022 10:58:29.
Logging verbosity is set to: Normal.     1>Project "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" on node 1 (build target(s)).
     1>BuildDafnyRuntimeJar:
         Compiling DafnyRuntimeJava to DafnyRuntimeJava/build/libs/DafnyRuntime.jar...
         ./gradlew -q build
       GenerateTargetFrameworkMonikerAttribute:
       Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
       CoreCompile:
       Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
       _CopyOutOfDateSourceItemsToOutputDirectory:
       Skipping target "_CopyOutOfDateSourceItemsToOutputDirectory" because all output files are up-to-date with respect to the input files.
       _CopyOutOfDateSourceItemsToOutputDirectoryAlways:
         Copying file from "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.cs" to "/Users/rwillems/Documents/SourceCode/dafny/Binaries/net6.0/DafnyRuntime.cs".
       GenerateBuildDependencyFile:
       Skipping target "GenerateBuildDependencyFile" because all output files are up-to-date with respect to the input files.
       CopyFilesToOutputDirectory:
         DafnyRuntime -> /Users/rwillems/Documents/SourceCode/dafny/Binaries/net6.0/DafnyRuntime.dll
     1>Done Building Project "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (build target(s)).
   1:2>Project "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" on node 1 (Pack target(s)).
   1:2>Project "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (1:2) is building "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (1:9) on node 1 (_GetFrameworkAssemblyReferences target(s)).
     1>BuildDafnyRuntimeJar:
         Compiling DafnyRuntimeJava to DafnyRuntimeJava/build/libs/DafnyRuntime.jar...
         ./gradlew -q build
     1>Done Building Project "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (_GetFrameworkAssemblyReferences target(s)).
   1:2>Project "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (1:2) is building "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (1:10) on node 1 (_GetFrameworkAssemblyReferences target(s)).
     1>/usr/local/share/dotnet/sdk/6.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1005: Assets file '/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/obj/project.assets.json' doesn't have a target for 'netstandard2.0'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project.
     1>Done Building Project "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (_GetFrameworkAssemblyReferences target(s)) -- FAILED.
     1>Done Building Project "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (Pack target(s)) -- FAILED.

Build FAILED.

       "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (Pack target) (1:2) ->
       "/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/DafnyRuntime.csproj" (_GetFrameworkAssemblyReferences target) (1:10) ->
       (ResolvePackageAssets target) -> 
         /usr/local/share/dotnet/sdk/6.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1005: Assets file '/Users/rwillems/Documents/SourceCode/dafny/Source/DafnyRuntime/obj/project.assets.json' doesn't have a target for 'netstandard2.0'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project.
```

I've reproduced this issue on a fresh Dafny checkout.

<!-- Does this PR need tests? Add them to `Test/` or to
`Source/*.Test/…` and run them with `dotnet test` -->

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
robin-aws added a commit that referenced this pull request Nov 17, 2022
…2795)

Fixes #2779. 

Another attempt after the previous attempt (#2604) had to be reverted
(#2710). I tried this with a fresh clone and didn't run into the Rider
problem described in #2710 - I'm relatively confident the
`<TargetFramework>net6.0</TargetFramework>` I've removed from
`Directory.Build.props` was to blame, and/or just needing to thoroughly
clean `bin` and `obj` directories.

Note that I am partially relying on post-hoc testing of the nightly
build packages after this is merged, to ensure the `net452` build
actually works on Windows.

Note also that the packaging warnings I refer to in one of the commit
messages are an existing, orthogonal issue:
#3069

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
@atomb atomb deleted the issue-2481 branch January 4, 2024 17:24
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.

DafnyRuntime nuget package should be compatible with older .NET frameworks
3 participants