From 5c4ee22fe64095b1cb0bcc9382777f0f9fef7eb7 Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Mon, 1 Apr 2019 17:17:49 -0700 Subject: [PATCH 1/6] Publish to Single-File This change implements support for publishing apps to a [single file](https://github.com/dotnet/designs/blob/master/accepted/single-file/design.md). * ``dotnet publish /p:PublishSingleFile=true`` causes the contents of the "original" publish directory to a single file in the actual publish directory * Files marked with the meta-data ``false`` are left in the publish directory unbundled. This includes PDB files by default * PDB files can be bundled into the single file by setting ``/p:IncludeSymbolsInSingleFile=true`` Publishing to a single file requires publishing wrt a RID using an apphost, because the generated file is the platform-specific AppHost executable with embedded dependencies. --- eng/Versions.props | 1 + .../HelloWorldWithSubDirs.csproj | 18 ++ .../HelloWorldWithSubDirs/Program.cs | 17 ++ .../HelloWorldWithSubDirs/Signature.stamp | 1 + .../.word | 1 + .../HelloWorldWithSubDirs/SmallNameDir/word | 1 + src/Tasks/Common/Resources/Strings.resx | 12 ++ src/Tasks/Common/Resources/xlf/Strings.cs.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.de.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.es.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.fr.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.it.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.ja.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.ko.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.pl.xlf | 17 +- .../Common/Resources/xlf/Strings.pt-BR.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.ru.xlf | 17 +- src/Tasks/Common/Resources/xlf/Strings.tr.xlf | 17 +- .../Common/Resources/xlf/Strings.zh-Hans.xlf | 17 +- .../Common/Resources/xlf/Strings.zh-Hant.xlf | 17 +- .../GenerateBundle.cs | 37 ++++ .../Microsoft.NET.Build.Tasks.csproj | 1 + .../targets/Microsoft.NET.Publish.targets | 94 +++++++-- ...oft.NET.RuntimeIdentifierInference.targets | 6 + .../GivenThatWeWantToPublishASingleFileApp.cs | 199 ++++++++++++++++++ 25 files changed, 584 insertions(+), 25 deletions(-) create mode 100644 src/Assets/TestProjects/HelloWorldWithSubDirs/HelloWorldWithSubDirs.csproj create mode 100644 src/Assets/TestProjects/HelloWorldWithSubDirs/Program.cs create mode 100644 src/Assets/TestProjects/HelloWorldWithSubDirs/Signature.stamp create mode 100644 src/Assets/TestProjects/HelloWorldWithSubDirs/SmallNameDir/This is a directory with a really long name for one that only contains a small file/.word create mode 100644 src/Assets/TestProjects/HelloWorldWithSubDirs/SmallNameDir/word create mode 100644 src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs create mode 100644 src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs diff --git a/eng/Versions.props b/eng/Versions.props index 8564178d7e54..9bf9ce613699 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -15,6 +15,7 @@ 15.4.8 15.4.8 2.1.0-preview2-26306-03 + 3.0.0-preview5-27615-04 2.0.1-servicing-26011-01 9.0.1 5.0.0-rtm.5821 diff --git a/src/Assets/TestProjects/HelloWorldWithSubDirs/HelloWorldWithSubDirs.csproj b/src/Assets/TestProjects/HelloWorldWithSubDirs/HelloWorldWithSubDirs.csproj new file mode 100644 index 000000000000..c24b9a827154 --- /dev/null +++ b/src/Assets/TestProjects/HelloWorldWithSubDirs/HelloWorldWithSubDirs.csproj @@ -0,0 +1,18 @@ + + + + Exe + netcoreapp3.0 + + + + + PreserveNewest + + + PreserveNewest + $(ExcludeContent) + + + + diff --git a/src/Assets/TestProjects/HelloWorldWithSubDirs/Program.cs b/src/Assets/TestProjects/HelloWorldWithSubDirs/Program.cs new file mode 100644 index 000000000000..27469c19e660 --- /dev/null +++ b/src/Assets/TestProjects/HelloWorldWithSubDirs/Program.cs @@ -0,0 +1,17 @@ +using System; +using System.IO; +using System.Reflection; + +namespace HelloWorldWithSubDirs +{ + class Program + { + static void Main(string[] args) + { + string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string hello = File.ReadAllText(Path.Combine(baseDir, "SmallNameDir", "word")); + string world = File.ReadAllText(Path.Combine(baseDir, "SmallNameDir", "This is a directory with a really long name for one that only contains a small file", ".word")); + Console.WriteLine($"{hello} {world}"); + } + } +} diff --git a/src/Assets/TestProjects/HelloWorldWithSubDirs/Signature.stamp b/src/Assets/TestProjects/HelloWorldWithSubDirs/Signature.stamp new file mode 100644 index 000000000000..11cfda16d9b2 --- /dev/null +++ b/src/Assets/TestProjects/HelloWorldWithSubDirs/Signature.stamp @@ -0,0 +1 @@ +Signed by .Net Core SDK devs. \ No newline at end of file diff --git a/src/Assets/TestProjects/HelloWorldWithSubDirs/SmallNameDir/This is a directory with a really long name for one that only contains a small file/.word b/src/Assets/TestProjects/HelloWorldWithSubDirs/SmallNameDir/This is a directory with a really long name for one that only contains a small file/.word new file mode 100644 index 000000000000..e5b8f9cece33 --- /dev/null +++ b/src/Assets/TestProjects/HelloWorldWithSubDirs/SmallNameDir/This is a directory with a really long name for one that only contains a small file/.word @@ -0,0 +1 @@ +World! \ No newline at end of file diff --git a/src/Assets/TestProjects/HelloWorldWithSubDirs/SmallNameDir/word b/src/Assets/TestProjects/HelloWorldWithSubDirs/SmallNameDir/word new file mode 100644 index 000000000000..5ab2f8a4323a --- /dev/null +++ b/src/Assets/TestProjects/HelloWorldWithSubDirs/SmallNameDir/word @@ -0,0 +1 @@ +Hello \ No newline at end of file diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx index 46a7002eebdf..d5df6b47ae0d 100644 --- a/src/Tasks/Common/Resources/Strings.resx +++ b/src/Tasks/Common/Resources/Strings.resx @@ -505,4 +505,16 @@ The following are names of parameters or literal values and should not be transl NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false. {StrBegin="NETSDK1096: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index ed5960f162e5..3f31b01da1d8 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -107,6 +107,21 @@ NETSDK1031: Sestavení nebo publikování nezávislé aplikace bez zadání parametru RuntimeIdentifier není podporované. Zadejte prosím buď parametr RuntimeIdentifier, nebo nastavte parametr SelfContained na hodnotu False. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: Hodnota TargetFramework {0} nebyla rozpoznána. Je možné, že obsahuje překlepy. Pokud tomu tak není, musíte vlastnosti TargetFrameworkIdentifier a TargetFrameworkVersion zadat explicitně. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index f8327e381027..0dd4a6af7293 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -107,6 +107,21 @@ NETSDK1031: Das Erstellen oder Veröffentlichen einer eigenständigen Anwendung ohne die Angabe eines RuntimeIdentifier wird nicht unterstützt. Geben Sie entweder einen RuntimeIdentifier an, oder legen Sie für SelfContained "False" fest. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: Der TargetFramework-Wert "{0}" wurde nicht erkannt. Unter Umständen ist die Schreibweise nicht korrekt. Andernfalls müssen die Eigenschaften TargetFrameworkIdentifier und/oder TargetFrameworkVersion explizit angegeben werden. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index 5fdafc4b124a..67a1ec791a80 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -107,6 +107,21 @@ NETSDK1031: No se admite compilar o publicar una aplicación autocontenida sin especificar un valor para RuntimeIdentifier. Especifique un valor para RuntimeIdentifier o establezca SelfContained en false. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: El valor de TargetFramework "{0}" no se reconoció. Puede que esté mal escrito. Si este no es el caso, las propiedades TargetFrameworkIdentifier o TargetFrameworkVersion se deben especificar explícitamente. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index e1280b69fa23..a7e06d99922b 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -107,6 +107,21 @@ NETSDK1031: La génération ou la publication d'une application autonome sans spécification de RuntimeIdentifier n'est pas prise en charge. Spécifiez RuntimeIdentifier ou affectez la valeur false à SelfContained. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: La valeur TargetFramework '{0}' n'a pas été reconnue. Elle est peut-être mal orthographiée. Sinon, vous devez spécifier explicitement les propriétés TargetFrameworkIdentifier et/ou TargetFrameworkVersion. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index 2377fbbd797f..c47d727bf999 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -107,6 +107,21 @@ NETSDK1031: non è possibile compilare o pubblicare un'applicazione indipendente senza specificare un elemento RuntimeIdentifier. Specificare un elemento RuntimeIdentifier o impostare SelfContained su false. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: il valore {0}' di TargetFramework non è stato riconosciuto. È possibile che sia stato digitato in modo errato. In caso contrario, le proprietà TargetFrameworkIdentifier e/o TargetFrameworkVersion devono essere specificate in modo esplicito. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index c73e0027ba35..c0fd9936abfc 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -107,6 +107,21 @@ NETSDK1031: RuntimeIdentifier を指定せずに自己完結型アプリケーションをビルドおよび発行することはサポートされていません。RuntimeIdentifier を指定するか SelfContained を false に設定してください。 {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: TargetFramework 値 '{0}' が認識されませんでした。つづりが間違っている可能性があります。間違っていない場合は、TargetFrameworkIdentifier または TargetFrameworkVersion プロパティ (あるいはその両方) を明示的に指定する必要があります。 @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index 3bec18472b0c..5b1ad9a26774 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -107,6 +107,21 @@ NETSDK1031: RuntimeIdentifier를 지정하지 않으면 자체 포함 애플리케이션의 빌드 또는 게시가 지원되지 않습니다. RuntimeIdentifier를 지정하거나 SelfContained를 false로 설정하세요. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: TargetFramework 값 '{0}'을(를) 인식하지 못했습니다. 철자가 틀렸을 수 있습니다. 그렇지 않은 경우 TargetFrameworkIdentifier 및/또는 TargetFrameworkVersion 속성을 명시적으로 지정해야 합니다. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index bb871f4e4b4f..dedb0b88007a 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -107,6 +107,21 @@ NETSDK1031: Kompilowanie i publikowanie aplikacji autonomicznej bez określania elementu RuntimeIdentifier nie jest obsługiwane. Określ element RuntimeIdentifier lub ustaw wartość false dla elementu SelfContained. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: Nie rozpoznano wartości „{0}” elementu TargetFramework. Być może wpisano ją niepoprawnie. Jeśli nie, należy jawnie określić właściwości TargetFrameworkIdentifier i/lub TargetFrameworkVersion. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index 7979dc3c4502..7811685cc972 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -107,6 +107,21 @@ NETSDK1031: Não há suporte para criar ou publicar um aplicativo autossuficiente sem especificar um RuntimeIdentifier. Especifique um RuntimeIdentifier ou defina SelfContained como falso. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: O valor '{0}' do TargetFramework não foi reconhecido. Ele pode ter sido escrito com ortografia incorreta. Caso contrário, as propriedades TargetFrameworkIdentifier e/ou TargetFrameworkVersion precisarão ser especificadas explicitamente. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index b963a4992dc4..7d17296bccad 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -107,6 +107,21 @@ NETSDK1031: сборка или публикация автономного приложения без указания RuntimeIdentifier не поддерживается. Укажите RuntimeIdentifier или присвойте свойству SelfContained значение "false". {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: значение "{0}" в TargetFramework не распознано. Возможно, оно содержит опечатку. Если это не так, задайте свойства TargetFrameworkIdentifier и (или) TargetFrameworkVersion явным образом. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index 1f0b0fd5182e..0685f9b18757 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -107,6 +107,21 @@ NETSDK1031: Bir RuntimeIdentifier belirtilmeden, bağımsız çalışan uygulamanın derlenmesi veya yayımlanması desteklenmez. Lütfen bir RuntimeIdentifier belirtin veya SelfContained değerini false olarak ayarlayın. {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: '{0}' TargetFramework değeri tanınmadı. Yanlış yazılmış olabilir. Sorun bundan kaynaklanmıyorsa, TargetFrameworkIdentifier ve/veya TargetFrameworkVersion özelliklerinin açık bir şekilde belirtilmesi gerekir. @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index 3e2e7258eb26..ef7d1faa781c 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -107,6 +107,21 @@ NETSDK1031: 不可在未指定 RuntimeIdentifier 的情况下生成或发布自包含应用程序。请指定 RuntimeIdentifier 或将 SelfContained 设置为 false。 {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: 未识别 TargetFramework 值“{0}”。可能是因为拼写错误。如果拼写正确,必须显式指定 TargetFrameworkIdentifier 和/或 TargetFrameworkVersion 属性。 @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index 4c5a116dfa1d..10efe60c7be1 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -107,6 +107,21 @@ NETSDK1031: 不支援在未指定 RuntimeIdentifier 的情況下,建置或發行獨立的應用程式。請指定 RuntimeIdentifier,或將 SelfContained 設為 False。 {StrBegin="NETSDK1031: "} + + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. + {StrBegin="NETSDK1097: "} + + + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + NETSDK1098: Applications published to a single-file are required to use the application host. Please either set PublishSingleFile to false or set UseAppHost to true. + {StrBegin="NETSDK1098: "} + + + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + NETSDK1099: Publishing to a single-file is currently only supported for executable applications. + {StrBegin="NETSDK1099: "} + NETSDK1013: The TargetFramework value '{0}' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. NETSDK1013: 無法辨識 TargetFramework 值 '{0}'。拼字可能有誤。若非此情況,即必須明確指定 TargetFrameworkIdentifier 及 (或) TargetFrameworkVersion 屬性。 @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl - \ No newline at end of file + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs new file mode 100644 index 000000000000..f882f744002d --- /dev/null +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs @@ -0,0 +1,37 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Build.Framework; +using Microsoft.NET.HostModel.Bundle; +using System.Collections.Generic; + +namespace Microsoft.NET.Build.Tasks +{ + public class GenerateBundle : TaskBase + { + [Required] + public ITaskItem[] FilesToBundle { get; set; } + [Required] + public string AppHostName { get; set; } + [Required] + public bool EmbedPDBs { get; set; } + [Required] + public string OutputDir { get; set; } + [Required] + public bool ShowDisgnosticOutput { get; set; } + + protected override void ExecuteCore() + { + Bundler bundler = new Bundler(AppHostName, OutputDir, EmbedPDBs, ShowDisgnosticOutput); + var fileSpec = new List(FilesToBundle.Length); + + foreach(var item in FilesToBundle) + { + fileSpec.Add(new FileSpec(sourcePath: item.ItemSpec, + bundleRelativePath: item.GetMetadata("RelativePath"))); + } + + bundler.GenerateBundle(fileSpec); + } + } +} diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj index d302f06b7f34..9410041e9314 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj +++ b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj @@ -45,6 +45,7 @@ + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets index a131a747d738..8973aa6d28d4 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets @@ -48,6 +48,7 @@ Copyright (c) .NET Foundation. All rights reserved. PrepareForPublish; ComputeAndCopyFilesToPublishDirectory; GeneratePublishDependencyFile; + BundlePublishDirectory; @@ -85,6 +86,9 @@ Copyright (c) .NET Foundation. All rights reserved. --> + + $(PublishDir)\ @@ -111,6 +115,8 @@ Copyright (c) .NET Foundation. All rights reserved. CopyFilesToPublishDirectory Copy all build outputs, satellites and other necessary files to the publish directory. + When publishing to a single file, only those files that are not bundled are copied. + The remaining files are directly written to the bundle file. ============================================================ --> + + <_ResolvedUnBundledFileToPublishPreserveNewest + Include="@(_ResolvedFileToPublishPreserveNewest)" + Condition="'$(PublishSingleFile)' != 'true' or + '%(_ResolvedFileToPublishPreserveNewest.ExcludeFromSingleFile)'=='true'" /> + + - + + <_ResolvedUnBundledFileToPublishAlways + Include="@(_ResolvedFileToPublishAlways)" + Condition="'$(PublishSingleFile)' != 'true' or + '%(_ResolvedFileToPublishAlways.ExcludeFromSingleFile)'=='true'" /> + + - - + <_ResolvedFileToPublishPreserveNewest Include="@(ResolvedFileToPublish)" - Condition="'%(ResolvedFileToPublish.CopyToPublishDirectory)'=='PreserveNewest'" /> + Condition="'%(ResolvedFileToPublish.CopyToPublishDirectory)'=='PreserveNewest'" /> <_ResolvedFileToPublishAlways Include="@(ResolvedFileToPublish)" - Condition="'%(ResolvedFileToPublish.CopyToPublishDirectory)'=='Always'" /> + Condition="'%(ResolvedFileToPublish.CopyToPublishDirectory)'=='Always'" /> - @@ -574,7 +596,7 @@ Copyright (c) .NET Foundation. All rights reserved. a non-empty value and the original behavior will be restored. --> <_GCTPDIKeepDuplicates>false - <_GCTPDIKeepMetadata>CopyToPublishDirectory;TargetPath + <_GCTPDIKeepMetadata>CopyToPublishDirectory;ExcludeFromSingleFile;TargetPath @@ -719,6 +741,47 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + + <_FilesToBundle Include="@(_ResolvedFileToPublishPreserveNewest)" + Condition="'%(_ResolvedFileToPublishPreserveNewest.ExcludeFromSingleFile)' != 'true'"/> + <_FilesToBundle Include="@(_ResolvedFileToPublishAlways)" + Condition="'%(_ResolvedFileToPublishPreserveNewest.ExcludeFromSingleFile)' != 'true'"/> + + + + + + + + + + true + false + + + + + + - - <_ResolvedUnBundledFileToPublishAlways + <_ResolvedUnbundledFileToPublishAlways Include="@(_ResolvedFileToPublishAlways)" Condition="'$(PublishSingleFile)' != 'true' or '%(_ResolvedFileToPublishAlways.ExcludeFromSingleFile)'=='true'" /> @@ -183,8 +183,8 @@ Copyright (c) .NET Foundation. All rights reserved. Not using SkipUnchangedFiles="true" because the application may want to change one of these files and not have an incremental build replace it. --> - + Outputs="$(PublishDir)$(AssemblyName)$(_NativeExecutableExtension)"> - - true - false + false From 25c2b423608690a37da83dbdcecdc55138af67cb Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Thu, 18 Apr 2019 16:15:17 -0700 Subject: [PATCH 5/6] Change an Array.Foreach() to foreach() loop. --- src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs index c86dab9cb334..3200e6f82770 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs @@ -26,10 +26,11 @@ protected override void ExecuteCore() var bundler = new Bundler(AppHostName, OutputDir, IncludeSymbols, ShowDisgnosticOutput); var fileSpec = new List(FilesToBundle.Length); - Array.ForEach(FilesToBundle, - item => fileSpec.Add( - new FileSpec(sourcePath: item.ItemSpec, - bundleRelativePath: item.GetMetadata(MetadataKeys.RelativePath)))); + foreach (var item in FilesToBundle) + { + fileSpec.Add(new FileSpec(sourcePath: item.ItemSpec, + bundleRelativePath:item.GetMetadata(MetadataKeys.RelativePath))); + } bundler.GenerateBundle(fileSpec); } From 4bb3c6954e055a57ec3111ac3d0b2d1f7c44f5e6 Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Thu, 18 Apr 2019 17:12:55 -0700 Subject: [PATCH 6/6] Fix a typo in a variablename Thanks @nguerrera --- src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs | 4 ++-- .../targets/Microsoft.NET.Publish.targets | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs index 3200e6f82770..2a1cd546e953 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs @@ -19,11 +19,11 @@ public class GenerateBundle : TaskBase [Required] public string OutputDir { get; set; } [Required] - public bool ShowDisgnosticOutput { get; set; } + public bool ShowDiagnosticOutput { get; set; } protected override void ExecuteCore() { - var bundler = new Bundler(AppHostName, OutputDir, IncludeSymbols, ShowDisgnosticOutput); + var bundler = new Bundler(AppHostName, OutputDir, IncludeSymbols, ShowDiagnosticOutput); var fileSpec = new List(FilesToBundle.Length); foreach (var item in FilesToBundle) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets index 2dd5b88ece70..51cf7dfb4d07 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets @@ -776,7 +776,7 @@ Copyright (c) .NET Foundation. All rights reserved. AppHostName="$(AssemblyName)$(_NativeExecutableExtension)" IncludeSymbols="$(IncludeSymbolsInSingleFile)" OutputDir="$(PublishDir)" - ShowDisgnosticOutput="false"/> + ShowDiagnosticOutput="false"/>