-
Notifications
You must be signed in to change notification settings - Fork 789
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
update F# templates to no longer unconditionally override FSharpTargetsPath. #2575
Conversation
…tsPath. This allows to set FSharpTargetsPath from outside.
@0x53A, |
@@ -70,12 +70,12 @@ | |||
<Choose> | |||
<When Condition="'$(VisualStudioVersion)' == '11.0'"> | |||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')"> | |||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> | |||
<FSharpTargetsPath Condition="'$(FSharpTargetsPath)'==''">$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a style note (easier to read), use spaced after and before "
, so like
Condition=" '$(FSharpTargetsPath)' == '' ">
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be fair to say that we don't do that spacing anywhere near consistently. So it's fine as it is. Checkout the line immediately above :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the condition could go on the "Choose" (I assume it supported conditions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsyme I have no idea, but Intellisense didn't offer Condition on Choose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsyme I was going to check that ... but it makes sense for it not to be there since Choose is itself a condition.
You could of course put it in a property group with a condition which is probably the right approach here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KevinRansom according to IntelliSense, there is not Choose inside PropertyGroup ...
@0x53A Can you also have a think what to do about the portable templates? These These should probably be changed to define a conditional "FSharpPortableTargetsPath" and check if it's not already set? And your prop file in the FSharp.Compiler.Tools nuget package can set this. @KevinRansom We know these templates are rapidly becoming legacy, but see the context in the linked issue above - we want to make sure that the FSharp.Compiler.Tools nuget package can be added to an existing project and things will work correctly, at least for as long as these templates continue to exist. |
@dsyme I added the same logic to the portables, but I am not sure if that is correct. Because the portable target includes a bunch of other files before including the standard target: https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/FSharp.Build/Microsoft.Portable.FSharp.targets So I think the better solution would be to define two properties, FSharpTargetsPath and PortableFSharpTargetsPath, where the default templates check against FSharpTargetsPath and the portable templates check against PortableFSharpTargetsPath. |
Well ... it does what says on the tin ... and it allows the TARGETSPATH to be set externally to the project file and with the FSharp.Tools nuget package you need some mechanism to point the project to it's version of the files. It would be fair to say I'm not a fan of that packaging either ... since it misses all of the multi-targeting support, and so is tied to building FSharp 4.1 Desktop apps and libraries. This change will work fine with portable libraries if VS is installed. And ... as you say ... everything will change with the next release ... although of course legacy projects like this will still work. So ... I am Okay with this change. |
Yes, please do exactly that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -70,12 +70,12 @@ | |||
<Choose> | |||
<When Condition="'$(VisualStudioVersion)' == '11.0'"> | |||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')"> | |||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> | |||
<FSharpTargetsPath Condition="'$(FSharpTargetsPath)'==''">$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsyme I was going to check that ... but it makes sense for it not to be there since Choose is itself a condition.
You could of course put it in a property group with a condition which is probably the right approach here.
Hmmm... @enricosada has integrated the .NET Core compiler into the FSharp.Compiler.Tools package as well, and as far as I understand it is the package referenced by So for the purposes of .NET Core right now I think that package is currently the way of distributing the compiler tools to the end user. I'd be very happy to bring that nuget package specification into this repo so we just have one compiler tools package (as long as we double check that we're also still packaging a "good" f# compiler for use on Mono). |
Actually, I am not a fan of it for the desktop, for the reasons I gave above. Coreclr packaging is a much different propostion.
|
ok |
@KevinRansom @enricosada Is there any reason we can't move both the spec of the FSharp.Compiler.Tools package and the whole of netcorecli-fsc into this repo? I find it really very confusing to have the .NET Core compiler packaging and delivery spread over three repos. At the moment bits and pieces of all three repos come into play. Right now we're going to have a hell of a time keeping all this in sync and publishing new editions of the compiler tooling quickly? |
Hmmm... thinking about this more.... Is there really any reason why the .NET Framework compiler bundled in that package can't be used to target portable, .NET Standard and .NET Core? As long as the reference assemblies are found (either by either Paket or the new MSBuild SDK)? Or were you referring to some other missing capability? I just want to know the limitations, thanks. My impression is that we're now in a world where all of these are othogonal
Are there any combinations of these that we don't expect to work, assuming reference assemblies are found correctly? |
as a note, for new sdk, i dont use the target file from vf# repo. i use FSharp.NET.Core.Sdk.targets, that's where
for
Nothing techically, is all about project development.
long term is a good idea to have it near FSharp.Core and FSharp.Compiler.Tools (so maybe in fsharp/fsharp too, just compiler+fsharcore+fcs? 😄 ). |
@dsyme But yes paket or nuget + msbuild + dotnet targeting packs + the right project file magic and it will work fine. |
ngen is one (and is good speed bump right). |
@dsyme annother limitation is new sdk cannot built .net framework 3.5 if matter for someone on mono for net45 you need reference assebmlies, but beacuse are not published as nuget package, you need to override a propertu for find these in mono installation |
Yes agreed
(Or the FSharp.Compiler.Tools fsc.exe)
Yes, the
Yes, agreed |
that should be for everything. Otherwise is possibile to mix ref to gac and ref to nuget package fsharp.core, and is annoying. |
Sorry, this whole pcl / multi-targeting / ... stuff is a bit out of my league. I have modified the spacing of the conditions to look like @enricosada proposed, is there anything else I should change? (Also, +1 to aquiring FSharp.Core from nuget. VS2017 includes a few selected packages, this should include FSharp.Core so that it will also work in an offline scenario) |
Don't worry, it's out of my league too :) It's a really big matrix unfortunately. Hopefully in 6 months a lot of it will really, truly be legacy-only. |
Yes. But the blockers are
|
@enrico Sada<mailto:enrico@sada.io> Changing the templates is fine … we know more changes are coming but until we get to the future … incremental improvements expand what can be done sooner.
|
@@ -70,12 +70,12 @@ | |||
<Choose> | |||
<When Condition="'$(VisualStudioVersion)' == '11.0'"> | |||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')"> | |||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> | |||
<FSharpTargetsPath Condition=" '$(FSharpTargetsPath)' == '' ">$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checkout the propertygroup condition above ...
Your code will only happen if ... the correct targets file exists in the regular vs location .... which probably defeats the point of the change.
So I think this section should probably look similar to this ... written in a text editor, completely untested.
The idea, set FSTP to the directory containing the target files.
For portable projects, change the last line to point to the portable target file.
<!-- Preset FSharpTargetsPath to the directory containing Microsoft.FSharp.Targets without trailing backslash, otherwise compute the location based on VisualStudio version -->
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="'$(FSharpTargetsPath)'=='' and Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="'$(FSharpTargetsPath)'=='' and Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)\Microsoft.FSharp.Targets" />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, FSharpTargetsPath pointed directly to the file. With your change, FSharpTargetsPath would point to the directory. Is that on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yes, the two conditions could be unified to a single one combined with and, but if I'm not missing anything that wouldn't actually change the logic? (Except maybe make it easier to read?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes ... then you can use the same code for portable. And a single variable to locate the target files.
@dsyme with commmunity is preferred ihmo. But There are lot of examples already in ms, aspnet use newtonsoft.json, xunit, etc. So is not a blocker to use non ms packages in templates in other products |
@dsyme @enricosada I think it's fine as it is with the community owning this package, it is an enthusiast packaging for enthusiast scenarios. |
You are correct that Newtownsoft JSON and Xunit have already set a precedent.
I would certainly be comfortable with the FSharp.Core package being handled by Microsoft. But perhaps what's most important is that it contains the signed binaries from Microsoft. |
@@ -70,12 +70,12 @@ | |||
<Choose> | |||
<When Condition="'$(VisualStudioVersion)' == '11.0'"> | |||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')"> | |||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> | |||
<FSharpTargetsPath Condition=" '$(FSharpTargetsPath)' == '' ">$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes ... then you can use the same code for portable. And a single variable to locate the target files.
<PropertyGroup> | ||
<PortableFSharpTargetsPath Condition=" '$(PortableFSharpTargetsPath)' == '' ">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.Portable.FSharp.Targets</PortableFSharpTargetsPath> | ||
</PropertyGroup> | ||
<Import Project="$(PortableFSharpTargetsPath)" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really ... you want to set two paths ... it seems a bit ... redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still ... I guess it's harmless enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as there is any way to override these targets files, I do not really care about if there is one variable or two. But FSharpTargetsPath
has historically pointed directly to the file, and a few people have already manually changed their project files and hardcoded this. So I think this would cause a bit of confusion, and the whole topic is already complex enough.
So if we want to use a single variable (which I actually also like), then I think we should use a different name, e.g. FSharpTargetsDir
, to make clear it points to the directory. @KevinRansom What do you think?
This allows to set FSharpTargetsPath from outside.
ref fsharp/fsharp#675