Skip to content

Commit aacf124

Browse files
swaroop-sridharnguerrera
authored andcommitted
Publish to Single-File (#3132)
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 ``<ExcludeFromSingleFile>false<ExcludeFromSingleFile>`` 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.
1 parent cfbe420 commit aacf124

File tree

25 files changed

+583
-25
lines changed

25 files changed

+583
-25
lines changed

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<MicrosoftBuildFrameworkVersion>15.4.8</MicrosoftBuildFrameworkVersion>
1616
<MicrosoftBuildUtilitiesCoreVersion>15.4.8</MicrosoftBuildUtilitiesCoreVersion>
1717
<MicrosoftExtensionsDependencyModelVersion>2.1.0-preview2-26306-03</MicrosoftExtensionsDependencyModelVersion>
18+
<MicrosoftNETHostModelVersion>3.0.0-preview5-27615-04</MicrosoftNETHostModelVersion>
1819
<NETStandardLibraryNETFrameworkVersion>2.0.1-servicing-26011-01</NETStandardLibraryNETFrameworkVersion>
1920
<NewtonsoftJsonVersion>9.0.1</NewtonsoftJsonVersion>
2021
<NuGetBuildTasksPackVersion>5.1.0-rtm.5921</NuGetBuildTasksPackVersion>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Content Include="$(MSBuildThisFileDirectory)\SmallNameDir\**\*.*" >
10+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
11+
</Content>
12+
<Content Include="$(MSBuildThisFileDirectory)\Signature.stamp" >
13+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
14+
<ExcludeFromSingleFile>$(ExcludeContent)</ExcludeFromSingleFile>
15+
</Content>
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
5+
namespace HelloWorldWithSubDirs
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
12+
string hello = File.ReadAllText(Path.Combine(baseDir, "SmallNameDir", "word"));
13+
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"));
14+
Console.WriteLine($"{hello} {world}");
15+
}
16+
}
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Signed by .Net Core SDK devs.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
World!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello

src/Tasks/Common/Resources/Strings.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,16 @@ The following are names of parameters or literal values and should not be transl
505505
<value>NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the ReadyToRun property to false.</value>
506506
<comment>{StrBegin="NETSDK1096: "}</comment>
507507
</data>
508+
<data name="CannotHaveSingleFileWithoutRuntimeIdentifier" xml:space="preserve">
509+
<value>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.</value>
510+
<comment>{StrBegin="NETSDK1097: "}</comment>
511+
</data>
512+
<data name="CannotHaveSingleFileWithoutAppHost" xml:space="preserve">
513+
<value>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.</value>
514+
<comment>{StrBegin="NETSDK1098: "}</comment>
515+
</data>
516+
<data name="CannotHaveSingleFileWithoutExecutable" xml:space="preserve">
517+
<value>NETSDK1099: Publishing to a single-file is only supported for executable applications.</value>
518+
<comment>{StrBegin="NETSDK1099: "}</comment>
519+
</data>
508520
</root>

src/Tasks/Common/Resources/xlf/Strings.cs.xlf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@
107107
<target state="translated">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.</target>
108108
<note>{StrBegin="NETSDK1031: "}</note>
109109
</trans-unit>
110+
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
111+
<source>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.</source>
112+
<target state="new">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.</target>
113+
<note>{StrBegin="NETSDK1097: "}</note>
114+
</trans-unit>
115+
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
116+
<source>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.</source>
117+
<target state="new">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.</target>
118+
<note>{StrBegin="NETSDK1098: "}</note>
119+
</trans-unit>
120+
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
121+
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
122+
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
123+
<note>{StrBegin="NETSDK1099: "}</note>
124+
</trans-unit>
110125
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
111126
<source>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.</source>
112127
<target state="translated">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ě.</target>
@@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
488503
</trans-unit>
489504
</body>
490505
</file>
491-
</xliff>
506+
</xliff>

src/Tasks/Common/Resources/xlf/Strings.de.xlf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@
107107
<target state="translated">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.</target>
108108
<note>{StrBegin="NETSDK1031: "}</note>
109109
</trans-unit>
110+
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
111+
<source>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.</source>
112+
<target state="new">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.</target>
113+
<note>{StrBegin="NETSDK1097: "}</note>
114+
</trans-unit>
115+
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
116+
<source>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.</source>
117+
<target state="new">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.</target>
118+
<note>{StrBegin="NETSDK1098: "}</note>
119+
</trans-unit>
120+
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
121+
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
122+
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
123+
<note>{StrBegin="NETSDK1099: "}</note>
124+
</trans-unit>
110125
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
111126
<source>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.</source>
112127
<target state="translated">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.</target>
@@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
488503
</trans-unit>
489504
</body>
490505
</file>
491-
</xliff>
506+
</xliff>

src/Tasks/Common/Resources/xlf/Strings.es.xlf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@
107107
<target state="translated">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.</target>
108108
<note>{StrBegin="NETSDK1031: "}</note>
109109
</trans-unit>
110+
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
111+
<source>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.</source>
112+
<target state="new">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.</target>
113+
<note>{StrBegin="NETSDK1097: "}</note>
114+
</trans-unit>
115+
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
116+
<source>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.</source>
117+
<target state="new">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.</target>
118+
<note>{StrBegin="NETSDK1098: "}</note>
119+
</trans-unit>
120+
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
121+
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
122+
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
123+
<note>{StrBegin="NETSDK1099: "}</note>
124+
</trans-unit>
110125
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
111126
<source>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.</source>
112127
<target state="translated">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.</target>
@@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
488503
</trans-unit>
489504
</body>
490505
</file>
491-
</xliff>
506+
</xliff>

src/Tasks/Common/Resources/xlf/Strings.fr.xlf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@
107107
<target state="translated">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.</target>
108108
<note>{StrBegin="NETSDK1031: "}</note>
109109
</trans-unit>
110+
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
111+
<source>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.</source>
112+
<target state="new">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.</target>
113+
<note>{StrBegin="NETSDK1097: "}</note>
114+
</trans-unit>
115+
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
116+
<source>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.</source>
117+
<target state="new">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.</target>
118+
<note>{StrBegin="NETSDK1098: "}</note>
119+
</trans-unit>
120+
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
121+
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
122+
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
123+
<note>{StrBegin="NETSDK1099: "}</note>
124+
</trans-unit>
110125
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
111126
<source>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.</source>
112127
<target state="translated">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.</target>
@@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
488503
</trans-unit>
489504
</body>
490505
</file>
491-
</xliff>
506+
</xliff>

src/Tasks/Common/Resources/xlf/Strings.it.xlf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@
107107
<target state="translated">NETSDK1031: non è possibile compilare o pubblicare un'applicazione indipendente senza specificare un elemento RuntimeIdentifier. Specificare un elemento RuntimeIdentifier o impostare SelfContained su false.</target>
108108
<note>{StrBegin="NETSDK1031: "}</note>
109109
</trans-unit>
110+
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
111+
<source>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.</source>
112+
<target state="new">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.</target>
113+
<note>{StrBegin="NETSDK1097: "}</note>
114+
</trans-unit>
115+
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
116+
<source>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.</source>
117+
<target state="new">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.</target>
118+
<note>{StrBegin="NETSDK1098: "}</note>
119+
</trans-unit>
120+
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
121+
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
122+
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
123+
<note>{StrBegin="NETSDK1099: "}</note>
124+
</trans-unit>
110125
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
111126
<source>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.</source>
112127
<target state="translated">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.</target>
@@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
488503
</trans-unit>
489504
</body>
490505
</file>
491-
</xliff>
506+
</xliff>

src/Tasks/Common/Resources/xlf/Strings.ja.xlf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@
107107
<target state="translated">NETSDK1031: RuntimeIdentifier を指定せずに自己完結型アプリケーションをビルドおよび発行することはサポートされていません。RuntimeIdentifier を指定するか SelfContained を false に設定してください。</target>
108108
<note>{StrBegin="NETSDK1031: "}</note>
109109
</trans-unit>
110+
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
111+
<source>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.</source>
112+
<target state="new">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.</target>
113+
<note>{StrBegin="NETSDK1097: "}</note>
114+
</trans-unit>
115+
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
116+
<source>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.</source>
117+
<target state="new">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.</target>
118+
<note>{StrBegin="NETSDK1098: "}</note>
119+
</trans-unit>
120+
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
121+
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
122+
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
123+
<note>{StrBegin="NETSDK1099: "}</note>
124+
</trans-unit>
110125
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
111126
<source>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.</source>
112127
<target state="translated">NETSDK1013: TargetFramework 値 '{0}' が認識されませんでした。つづりが間違っている可能性があります。間違っていない場合は、TargetFrameworkIdentifier または TargetFrameworkVersion プロパティ (あるいはその両方) を明示的に指定する必要があります。</target>
@@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
488503
</trans-unit>
489504
</body>
490505
</file>
491-
</xliff>
506+
</xliff>

0 commit comments

Comments
 (0)