diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index 02c3306b2d..0881e8c917 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -581,7 +581,7 @@ let SetDeterministicSwitch (tcConfigB: TcConfigBuilder) switch = let SetReferenceAssemblyOnlySwitch (tcConfigB: TcConfigBuilder) switch = match tcConfigB.emitMetadataAssembly with - | MetadataAssemblyGeneration.None -> + | MetadataAssemblyGeneration.None when tcConfigB.standalone = false && tcConfigB.extraStaticLinkRoots.IsEmpty -> tcConfigB.emitMetadataAssembly <- if (switch = OptionSwitch.On) then MetadataAssemblyGeneration.ReferenceOnly @@ -591,7 +591,7 @@ let SetReferenceAssemblyOnlySwitch (tcConfigB: TcConfigBuilder) switch = let SetReferenceAssemblyOutSwitch (tcConfigB: TcConfigBuilder) outputPath = match tcConfigB.emitMetadataAssembly with - | MetadataAssemblyGeneration.None -> + | MetadataAssemblyGeneration.None when tcConfigB.standalone = false && tcConfigB.extraStaticLinkRoots.IsEmpty -> if FileSystem.IsInvalidPathShim outputPath then error (Error(FSComp.SR.optsInvalidRefOut (), rangeCmdArgs)) else @@ -1304,9 +1304,12 @@ let advancedFlagsFsc tcConfigB = "standalone", tagNone, OptionUnit(fun _ -> - tcConfigB.openDebugInformationForLaterStaticLinking <- true - tcConfigB.standalone <- true - tcConfigB.implicitlyResolveAssemblies <- true), + match tcConfigB.emitMetadataAssembly with + | MetadataAssemblyGeneration.None -> + tcConfigB.openDebugInformationForLaterStaticLinking <- true + tcConfigB.standalone <- true + tcConfigB.implicitlyResolveAssemblies <- true + | _ -> error (Error(FSComp.SR.optsInvalidRefAssembly (), rangeCmdArgs))), None, Some(FSComp.SR.optsStandalone ()) ) @@ -1315,8 +1318,11 @@ let advancedFlagsFsc tcConfigB = "staticlink", tagFile, OptionString(fun s -> - tcConfigB.extraStaticLinkRoots <- tcConfigB.extraStaticLinkRoots @ [ s ] - tcConfigB.implicitlyResolveAssemblies <- true), + match tcConfigB.emitMetadataAssembly with + | MetadataAssemblyGeneration.None -> + tcConfigB.extraStaticLinkRoots <- tcConfigB.extraStaticLinkRoots @ [ s ] + tcConfigB.implicitlyResolveAssemblies <- true + | _ -> error (Error(FSComp.SR.optsInvalidRefAssembly (), rangeCmdArgs))), None, Some(FSComp.SR.optsStaticlink ()) ) diff --git a/src/Compiler/Driver/StaticLinking.fs b/src/Compiler/Driver/StaticLinking.fs index 5ad9ff15f4..17bc488276 100644 --- a/src/Compiler/Driver/StaticLinking.fs +++ b/src/Compiler/Driver/StaticLinking.fs @@ -514,10 +514,6 @@ let StaticLink (ctok, tcConfig: TcConfig, tcImports: TcImports, ilGlobals: ILGlo id else (fun ilxMainModule -> - match tcConfig.emitMetadataAssembly with - | MetadataAssemblyGeneration.None -> () - | _ -> error (Error(FSComp.SR.optsInvalidRefAssembly (), rangeCmdArgs)) - ReportTime tcConfig "Find assembly references" let dependentILModules = diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 2fca7afeb6..1c3623d2a1 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1165,7 +1165,7 @@ fscTooManyErrors,"Exiting - too many errors" 2025,fscAssemblyWildcardAndDeterminism,"An %s specified version '%s', but this value is a wildcard, and you have requested a deterministic build, these are in conflict." 2028,optsInvalidPathMapFormat,"Invalid path map. Mappings must be comma separated and of the format 'path=sourcePath'" 2029,optsInvalidRefOut,"Invalid reference assembly path'" -2030,optsInvalidRefAssembly,"Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together." +2030,optsInvalidRefAssembly,"Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'." 3000,etIllegalCharactersInNamespaceName,"Character '%s' is not allowed in provided namespace name '%s'" 3001,etNullOrEmptyMemberName,"The provided type '%s' returned a member with a null or empty member name" 3002,etNullMember,"The provided type '%s' returned a null member" diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 9f1b557acb..80a628d759 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Neplatné použití generování referenčního sestavení, nepoužívejte --staticlink ani --refonly a --refout společně. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Neplatné použití generování referenčního sestavení, nepoužívejte --staticlink ani --refonly a --refout společně. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index fad70824e3..595eedd84a 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Ungültige Verwendung der Ausgabe einer Referenzassembly. Verwenden Sie nicht "--staticlink" oder "--refonly" und "--refout" zusammen. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Ungültige Verwendung der Ausgabe einer Referenzassembly. Verwenden Sie nicht "--staticlink" oder "--refonly" und "--refout" zusammen. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 5402a968af..3e2407c154 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Uso no válido de emitir un ensamblado de referencia, no use "--staticlink', or '--refonly' and '--refout" de forma conjunta. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Uso no válido de emitir un ensamblado de referencia, no use "--staticlink', or '--refonly' and '--refout" de forma conjunta. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index aadf83ade0..54cad306cd 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Utilisation non valide de l’émission d’un assembly de référence. N’utilisez pas '--staticlink' ni '--refonly' et '--refout' ensemble. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Utilisation non valide de l’émission d’un assembly de référence. N’utilisez pas '--staticlink' ni '--refonly' et '--refout' ensemble. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 8b681eb4a1..007dc9646b 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Utilizzo non valido della creazione di un assembly di riferimento. Non usare insieme '--staticlink' o '--refonly' e '--refout'. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Utilizzo non valido della creazione di un assembly di riferimento. Non usare insieme '--staticlink' o '--refonly' e '--refout'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 4b6c944481..3d5ed3c9da 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - 参照アセンブリの生成の使用が無効です。'--staticlink'、または '--refonly' と '--refout' を同時に使用しないでください。 + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + 参照アセンブリの生成の使用が無効です。'--staticlink'、または '--refonly' と '--refout' を同時に使用しないでください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 40973f9e1a..40bbf8e988 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - 참조 어셈블리 내보내기를 잘못 사용했습니다. '--staticlink' 또는 '--refonly' 및 '--refout'을 함께 사용하지 마세요. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + 참조 어셈블리 내보내기를 잘못 사용했습니다. '--staticlink' 또는 '--refonly' 및 '--refout'을 함께 사용하지 마세요. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 9b4b9dab2e..136d0b7f29 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Nieprawidłowe użycie emitowania zestawu odwołania, nie używaj razem elementów „--staticlink” ani „--refonly” i „--refout”. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Nieprawidłowe użycie emitowania zestawu odwołania, nie używaj razem elementów „--staticlink” ani „--refonly” i „--refout”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 3307d01761..7bd9a3a800 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Uso inválido de emitir um assembly de referência, não use '--staticlink' ou '--reutilly' e '--refout' juntos. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Uso inválido de emitir um assembly de referência, não use '--staticlink' ou '--reutilly' e '--refout' juntos. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index d9de5f772a..9fd17e474e 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Недопустимое использование при создании базовой сборки. Не используйте "--staticlink" или "--refonly" и "--refout" вместе. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Недопустимое использование при создании базовой сборки. Не используйте "--staticlink" или "--refonly" и "--refout" вместе. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 3cd9f827dc..467e88ffe7 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - Başvuru bütünleştirilmiş kodunun oluşturulması için geçersiz kullanım: '--staticlink' veya '--refonly' ile '--refout' birlikte kullanılmaz. + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + Başvuru bütünleştirilmiş kodunun oluşturulması için geçersiz kullanım: '--staticlink' veya '--refonly' ile '--refout' birlikte kullanılmaz. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index d733d0c103..de4213c22d 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - 发出引用程序集的使用无效,请勿同时使用“--staticlink”或“--refonly”和“--refout”。 + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + 发出引用程序集的使用无效,请勿同时使用“--staticlink”或“--refonly”和“--refout”。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 1d7aec7be9..d104380d61 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -538,8 +538,8 @@ - Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together. - 發出參考組件的使用無效,請勿同時使用 '--staticlink' 或 '--refonly' 和 '--refout'。 + Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'. + 發出參考組件的使用無效,請勿同時使用 '--staticlink' 或 '--refonly' 和 '--refout'。 diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj index 95f3929fd8..ab0d33bd42 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj @@ -7,7 +7,6 @@ NO_GENERATIVE IS_DESIGNTIME $(FSharpCoreShippedPackageVersionValue) - false diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj index b90ea4de6f..c157669ba0 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj @@ -7,7 +7,6 @@ false NO_GENERATIVE $(FSharpCoreShippedPackageVersionValue) - false diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj index 6a00d20357..6dc2609483 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj @@ -7,7 +7,6 @@ $(FSharpCoreShippedPackageVersionValue) typeproviders $(NoWarn);NU5100;NU5118 - false diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/refonlyrefout.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/refonlyrefout.fs new file mode 100644 index 0000000000..e4d576f894 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/refonlyrefout.fs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.ComponentTests.CompilerOptions + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module RefOnlyRefOut = + + // Test refout/refonly alongside standalone + [] + let ``fsc --refonly --standalone``() = + FSharp """ + """ + |> asExe + |> withOptions ["--refonly"; "--standalone"] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.") + ] + + [] + let ``fsc --standalone --refonly ``() = + FSharp """ + """ + |> asExe + |> withOptions ["--standalone"; "--refonly"] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.") + ] + + [] + let ``fsc --refout:. --standalone``() = + FSharp """ + """ + |> asExe + |> withOptions ["--refout:."; "--standalone"] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.") + ] + + [] + let ``fsc --standalone --refout:.``() = + FSharp """ + """ + |> asExe + |> withOptions ["--standalone"; "--refout:."] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.") + ] + + // Test refout/refonly alongside staticlink + [] + let ``fsc --refonly --staticlink:.``() = + FSharp """ + """ + |> asExe + |> withOptions ["--refonly"; "--staticlink:."] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.") + ] + + [] + let ``fsc --staticlink:. --refonly ``() = + FSharp """ + """ + |> asExe + |> withOptions ["--staticlink:."; "--refonly"] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.") + ] + + [] + let ``fsc --refout:. --staticlink:.``() = + FSharp """ + """ + |> asExe + |> withOptions ["--refout:."; "--staticlink:."] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.") + ] + + [] + let ``fsc --staticlink:. --refout:.``() = + FSharp """ + """ + |> asExe + |> withOptions ["--staticlink:."; "--refout:."] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 91555d0106..c5dc63107f 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -196,6 +196,7 @@ + diff --git a/tests/fsharp/Compiler/CodeGen/EmittedIL/ReferenceAssemblyTests.fs b/tests/fsharp/Compiler/CodeGen/EmittedIL/ReferenceAssemblyTests.fs index 9020c5d85e..0a3acccc85 100644 --- a/tests/fsharp/Compiler/CodeGen/EmittedIL/ReferenceAssemblyTests.fs +++ b/tests/fsharp/Compiler/CodeGen/EmittedIL/ReferenceAssemblyTests.fs @@ -393,44 +393,6 @@ let test() = }""" ] - [] - let ``Can't use both --refonly and --staticlink``() = - let src = - """ -module ReferenceAssembly - -open System - -let test() = - Console.WriteLine("Hello World!") - """ - - FSharp src - |> withOptions ["--staticlink:foo"; "--refonly"] - |> compile - |> shouldFail - |> withSingleDiagnostic (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.") - |> ignore - - [] - let ``Can't use both --refoout and --staticlink``() = - let src = - """ -module ReferenceAssembly - -open System - -let test() = - Console.WriteLine("Hello World!") - """ - - FSharp src - |> withOptions ["--staticlink:foo"; "--refout:foo"] - |> compile - |> shouldFail - |> withSingleDiagnostic (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.") - |> ignore - [] let ``Internal DU type doesn't generate any properties/methods without IVT`` () = FSharp """