-
Notifications
You must be signed in to change notification settings - Fork 325
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
Auto-generate F# program file #1664
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
72cdfdc
Auto-generate F# program file
saul 4e68110
Update Microsoft.NET.Test.Sdk.targets
saul 13f4d46
Update Microsoft.NET.Test.Sdk.targets
saul ba470a5
Don't generate a Program.fs if one already exists.
saul 6e1aa3c
Merge branch 'master' into patch-1
saul c888e5b
Merge branch 'master' into patch-1
smadala c33be0e
Merge branch 'master' into patch-1
singhsarab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ | |
Condition="'$(GenerateProgramFile)' == 'true'" /> | ||
|
||
<Target Name="CoreGenerateProgramFile" | ||
Condition="'$(Language)'=='VB' or '$(Language)'=='C#'" | ||
Condition="'$(Language)'=='VB' or '$(Language)'=='C#' or '$(Language)'=='F#'" | ||
Inputs="$(MSBuildAllProjects)" | ||
Outputs="$(GeneratedProgramFile)"> | ||
|
||
|
@@ -76,15 +76,31 @@ | |
<Line Include="End Sub"/> | ||
<Line Include="End Module"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(Language)'=='F#'"> | ||
<Line Include="// <auto-generated> This file has been auto generated. </auto-generated>"/> | ||
<Line Include="module AutoGeneratedProgram"/> | ||
<Line Include="[<EntryPoint>]"/> | ||
<Line Include="[<Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode>]"/> | ||
<Line Include="let main _ = 0"/> | ||
</ItemGroup> | ||
|
||
<WriteLinesToFile | ||
File="$(GeneratedProgramFile)" Lines="@(Line)" Overwrite="true" Encoding="Unicode"> | ||
</WriteLinesToFile> | ||
|
||
<!-- | ||
Compile Include the generated Program File | ||
--> | ||
<ItemGroup> | ||
<ItemGroup Condition="'$(Language)'!='F#'"> | ||
<Compile Include="$(GeneratedProgramFile)"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(Language)'=='F#'"> | ||
<ProgramCompiles Include="@(Compile)" Condition=" '%(Identity)' == 'Program.fs' "/> | ||
<CompileAfter Include="$(GeneratedProgramFile)" Condition="@(ProgramCompiles->Count()) == 0"/> | ||
</ItemGroup> | ||
|
||
<Warning Condition=" @(ProgramCompiles->Count()) != 0 " Text="A 'Program.fs' file can be automatically generated for F# .NET Core test projects. To fix this warning, either delete the file from the project, or set the <GenerateProgramFile> property to 'false'." /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might need localization. We will take it in separate PR if required. |
||
</Target> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not sure
runtimeconfig.*.json
will gets generates becauseCompileAfter
?FYI dotnet/sdk#201 #287.
@saul did you test simple unit test project of F# with your changes?
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 think I understood what is CompileAfter. Now it makes sense after reading issue one more time.
I have checked out your branch and verified E2E scenario. Below are the issue we need to address.
This can be fixed by removing
<Compile Include="Program.fs" />
from template fsproj here and removing Program.fs, We can address this with separate https://github.com/dotnet/templating PRMicrosoft.NET.Test.Sdk
package.This can be fixed by adding check here that don't include
GeneratedProgramFile
inCompileAfter
ifCompile
item group containsProgram.fs
.@saul Can you please fix the seconds issue in this PR?
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.
Thanks @smadala - I've fixed the second problem.
I've added a warning:
A 'Program.fs' file can be automatically generated for F# .NET Core test projects. To fix this warning, either delete the file from the project, or set the <GenerateProgramFile> property to 'false'.
This lets the user either remove their Program.fs, or disables
<GenerateProgramFile>
if they need a complex Program.fs for whatever reason.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.
@saul Adding warning is very good idea.