Skip to content

Commit

Permalink
Publish to Single-File (#3132)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
swaroop-sridhar authored and nguerrera committed Apr 19, 2019
1 parent cfbe420 commit aacf124
Show file tree
Hide file tree
Showing 25 changed files with 583 additions and 25 deletions.
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<MicrosoftBuildFrameworkVersion>15.4.8</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildUtilitiesCoreVersion>15.4.8</MicrosoftBuildUtilitiesCoreVersion>
<MicrosoftExtensionsDependencyModelVersion>2.1.0-preview2-26306-03</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftNETHostModelVersion>3.0.0-preview5-27615-04</MicrosoftNETHostModelVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.1-servicing-26011-01</NETStandardLibraryNETFrameworkVersion>
<NewtonsoftJsonVersion>9.0.1</NewtonsoftJsonVersion>
<NuGetBuildTasksPackVersion>5.1.0-rtm.5921</NuGetBuildTasksPackVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)\SmallNameDir\**\*.*" >
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\Signature.stamp" >
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>$(ExcludeContent)</ExcludeFromSingleFile>
</Content>
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions src/Assets/TestProjects/HelloWorldWithSubDirs/Program.cs
Original file line number Diff line number Diff line change
@@ -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}");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Signed by .Net Core SDK devs.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello
12 changes: 12 additions & 0 deletions src/Tasks/Common/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,16 @@ The following are names of parameters or literal values and should not be transl
<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>
<comment>{StrBegin="NETSDK1096: "}</comment>
</data>
<data name="CannotHaveSingleFileWithoutRuntimeIdentifier" xml:space="preserve">
<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>
<comment>{StrBegin="NETSDK1097: "}</comment>
</data>
<data name="CannotHaveSingleFileWithoutAppHost" xml:space="preserve">
<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>
<comment>{StrBegin="NETSDK1098: "}</comment>
</data>
<data name="CannotHaveSingleFileWithoutExecutable" xml:space="preserve">
<value>NETSDK1099: Publishing to a single-file is only supported for executable applications.</value>
<comment>{StrBegin="NETSDK1099: "}</comment>
</data>
</root>
17 changes: 16 additions & 1 deletion src/Tasks/Common/Resources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@
<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>
<note>{StrBegin="NETSDK1031: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
<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>
<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>
<note>{StrBegin="NETSDK1097: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
<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>
<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>
<note>{StrBegin="NETSDK1098: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
<note>{StrBegin="NETSDK1099: "}</note>
</trans-unit>
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
<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>
<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>
Expand Down Expand Up @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
</trans-unit>
</body>
</file>
</xliff>
</xliff>
17 changes: 16 additions & 1 deletion src/Tasks/Common/Resources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@
<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>
<note>{StrBegin="NETSDK1031: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
<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>
<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>
<note>{StrBegin="NETSDK1097: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
<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>
<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>
<note>{StrBegin="NETSDK1098: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
<note>{StrBegin="NETSDK1099: "}</note>
</trans-unit>
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
<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>
<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>
Expand Down Expand Up @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
</trans-unit>
</body>
</file>
</xliff>
</xliff>
17 changes: 16 additions & 1 deletion src/Tasks/Common/Resources/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@
<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>
<note>{StrBegin="NETSDK1031: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
<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>
<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>
<note>{StrBegin="NETSDK1097: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
<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>
<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>
<note>{StrBegin="NETSDK1098: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
<note>{StrBegin="NETSDK1099: "}</note>
</trans-unit>
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
<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>
<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>
Expand Down Expand Up @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
</trans-unit>
</body>
</file>
</xliff>
</xliff>
17 changes: 16 additions & 1 deletion src/Tasks/Common/Resources/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@
<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>
<note>{StrBegin="NETSDK1031: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
<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>
<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>
<note>{StrBegin="NETSDK1097: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
<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>
<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>
<note>{StrBegin="NETSDK1098: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
<note>{StrBegin="NETSDK1099: "}</note>
</trans-unit>
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
<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>
<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>
Expand Down Expand Up @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
</trans-unit>
</body>
</file>
</xliff>
</xliff>
17 changes: 16 additions & 1 deletion src/Tasks/Common/Resources/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@
<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>
<note>{StrBegin="NETSDK1031: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
<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>
<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>
<note>{StrBegin="NETSDK1097: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
<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>
<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>
<note>{StrBegin="NETSDK1098: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
<note>{StrBegin="NETSDK1099: "}</note>
</trans-unit>
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
<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>
<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>
Expand Down Expand Up @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
</trans-unit>
</body>
</file>
</xliff>
</xliff>
17 changes: 16 additions & 1 deletion src/Tasks/Common/Resources/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@
<target state="translated">NETSDK1031: RuntimeIdentifier を指定せずに自己完結型アプリケーションをビルドおよび発行することはサポートされていません。RuntimeIdentifier を指定するか SelfContained を false に設定してください。</target>
<note>{StrBegin="NETSDK1031: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutRuntimeIdentifier">
<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>
<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>
<note>{StrBegin="NETSDK1097: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutAppHost">
<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>
<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>
<note>{StrBegin="NETSDK1098: "}</note>
</trans-unit>
<trans-unit id="CannotHaveSingleFileWithoutExecutable">
<source>NETSDK1099: Publishing to a single-file is only supported for executable applications.</source>
<target state="new">NETSDK1099: Publishing to a single-file is only supported for executable applications.</target>
<note>{StrBegin="NETSDK1099: "}</note>
</trans-unit>
<trans-unit id="CannotInferTargetFrameworkIdentifierAndVersion">
<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>
<target state="translated">NETSDK1013: TargetFramework 値 '{0}' が認識されませんでした。つづりが間違っている可能性があります。間違っていない場合は、TargetFrameworkIdentifier または TargetFrameworkVersion プロパティ (あるいはその両方) を明示的に指定する必要があります。</target>
Expand Down Expand Up @@ -488,4 +503,4 @@ The following are names of parameters or literal values and should not be transl
</trans-unit>
</body>
</file>
</xliff>
</xliff>
Loading

0 comments on commit aacf124

Please sign in to comment.