dotnet-script / dotnet-script

Run C# scripts from the .NET CLI.
MIT License
2.67k stars 162 forks source link

How to use dotnet script publish? #561

Open EmilyGraceSeville7cf opened 4 years ago

EmilyGraceSeville7cf commented 4 years ago

How to use dotnet script publish? dotnet script publish <some-file-name>.csx fails with dotnet publish failed with result '1'.

image

seesharper commented 4 years ago

Could you do a dotnet script --info and paste the output here?

Also try to execute the publish command using the debug option

dotnet script --debug publish main.csx

EmilyGraceSeville7cf commented 4 years ago

dotnet script --info produced the following result:

Version             : 0.53.0
Install location    : C:\Users\Alvin Seville\.dotnet\tools\.store\dotnet-script\0.53.0\dotnet-script\0.53.0\tools\netcoreapp3.1\any
Target framework    : netcoreapp3.1
.NET Core version   : 3.1.5
Platform identifier : win
Runtime identifier  : win10-x64

dotnet script --debug publish main.csx failed with this error:

info: Dotnet.Script.Core.ScriptCompiler[0]
      Current runtime is 'win'.
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      Creating project file for C:\Users\Alvin Seville\Desktop\New folder\main.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptParser[0]
      Parsing C:\Users\Alvin Seville\Desktop\New folder\main.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      Project file saved to C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\script.csproj
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      <?xml version="1.0" encoding="utf-8"?>
      <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
          <OutputType>Exe</OutputType>
          <TargetFramework>netcoreapp3.1</TargetFramework>
          <LangVersion>latest</LangVersion>
        </PropertyGroup>
        <ItemGroup></ItemGroup>
        <Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
          <WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
        </Target>
      </Project>
dbug: Dotnet.Script.DependencyModel.Context.CachedRestorer[0]
      Skipping restore. C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\script.csproj and C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\script.csproj.cache are identical.
dbug: Dotnet.Script.DependencyModel.Context.ProfiledRestorer[0]
      Restoring C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\script.csproj took 1ms
dbug: Dotnet.Script.Core.ScriptCompiler[0]
      Configuration/Optimization mode: Debug
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Executing 'dotnet publish "C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj" -c Release -r win10-x64 -o "C:\Users\Alvin Seville\Desktop\New folder\publish\win10-x64" /p:PublishSingleFile=true /p:DebugType=Embedded'
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Copyright (C) Microsoft Corporation. All rights reserved.
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
        Determining projects to restore...
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
        Restored C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj (in 529 ms).
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      C:\Program Files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      C:\Program Files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis.Scripting" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      C:\Program Files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "System.Buffers" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\main.AssemblyInfo.cs(13,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\main.AssemblyInfo.cs(14,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\main.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\main.AssemblyInfo.cs(16,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\main.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\main.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\main.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [C:\Users\Alvin Seville\AppData\Local\Temp\dotnet-script\C\Users\Alvin Seville\Desktop\New folder\netcoreapp3.1\main.csproj]
System.Exception: dotnet publish failed with result '1'
   at Dotnet.Script.Core.ScriptPublisher.CreateExecutable[TReturn,THost](ScriptContext context, LogFactory logFactory, String runtimeIdentifier, String executableFileName) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\ScriptPublisher.cs:line 98
   at Dotnet.Script.Core.Commands.PublishCommand.Execute(PublishCommandOptions options) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\Commands\PublishCommand.cs:line 45
   at Dotnet.Script.Program.<>c__DisplayClass4_4.<Wain>b__14() in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 180
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.cs:line 611
   at Dotnet.Script.Program.Wain(String[] args) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 251
   at Dotnet.Script.Program.Main(String[] args) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 27
alexalok commented 4 years ago

I am facing the same exact issue.

Running dotnet script --info yields

Version             : 0.53.0
Install location    : C:\Users\Work\.dotnet\tools\.store\dotnet-script\0.53.0\dotnet-script\0.53.0\tools\netcoreapp3.1\any
Target framework    : netcoreapp3.1
.NET Core version   : 3.1.5
Platform identifier : win
Runtime identifier  : win10-x64

and dotnet script --debug publish .\delete_empty_lochistory_entries.csx results in

info: Dotnet.Script.Core.ScriptCompiler[0]
      Current runtime is 'win'.
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      Creating project file for C:\sources-work\FamillityApi\scripts\.\delete_empty_lochistory_entries.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptParser[0]
      Parsing C:\sources-work\FamillityApi\scripts\.\delete_empty_lochistory_entries.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      Project file saved to C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\script.csproj
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      <?xml version="1.0" encoding="utf-8"?>
      <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
          <OutputType>Exe</OutputType>
          <TargetFramework>netcoreapp3.1</TargetFramework>
          <LangVersion>latest</LangVersion>
        </PropertyGroup>
        <ItemGroup>
          <PackageReference Include="Dapper" Version="2.0.35" />
          <PackageReference Include="MySqlConnector" Version="1.0.0" />
        </ItemGroup>
        <Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
          <WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
        </Target>
      </Project>
dbug: Dotnet.Script.DependencyModel.Context.CachedRestorer[0]
      Skipping restore. C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\script.csproj and C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\script.csproj.cache are identical.
dbug: Dotnet.Script.DependencyModel.Context.ProfiledRestorer[0]
      Restoring C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\script.csproj took 2ms
dbug: Dotnet.Script.Core.ScriptCompiler[0]
      Configuration/Optimization mode: Debug
dbug: Dotnet.Script.Core.ScriptCompiler[0]
      Suppressed diagnostic CS1702: warning CS1702: Assuming assembly reference 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'MySqlConnector' matches identity 'System.Data.Common, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Data.Common', you may need to supply runtime policy
dbug: Dotnet.Script.Core.ScriptCompiler[0]
      Suppressed diagnostic CS1702: warning CS1702: Assuming assembly reference 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'MySqlConnector' matches identity 'System.Data.Common, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Data.Common', you may need to supply runtime policy
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Executing 'dotnet publish "C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\delete_empty_lochistory_entries.csproj" -c Release -r win10-x64 -o "C:\sources-work\FamillityApi\scripts\.\publish\win10-x64" /p:PublishSingleFile=true /p:DebugType=Embedded'
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Copyright (C) Microsoft Corporation. All rights reserved.
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
        Determining projects to restore...
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
        All projects are up-to-date for restore.
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      c:\program files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      c:\program files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis.Scripting" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      c:\program files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "System.Buffers" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(13,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(14,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(16,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
System.Exception: dotnet publish failed with result '1'
   at Dotnet.Script.Core.ScriptPublisher.CreateExecutable[TReturn,THost](ScriptContext context, LogFactory logFactory, String runtimeIdentifier, String executableFileName) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\ScriptPublisher.cs:line 98
   at Dotnet.Script.Core.Commands.PublishCommand.Execute(PublishCommandOptions options) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\Commands\PublishCommand.cs:line 45
   at Dotnet.Script.Program.<>c__DisplayClass4_4.<Wain>b__14() in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 180
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.cs:line 611
   at Dotnet.Script.Program.Wain(String[] args) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 251
   at Dotnet.Script.Program.Main(String[] args) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 27
LostBeard commented 2 years ago

Same problem here. I'm getting the same "Duplicate ... attribute" errors and then the "failed with result '1'" when I run with --debug.

I'm not sure how to post my --debug output without losing the formatting or xml.

dotnet script --info Version : 1.2.1 Install location : C:\Users\Owner.dotnet\tools.store\dotnet-script\1.2.1\dotnet-script\1.2.1\tools\net5.0\any Target framework : net5.0 .NET Core version : 5.0.9 Platform identifier : win Runtime identifier : win10-x64

dameng324 commented 2 years ago

I am facing the same exact issue.

Running dotnet script --info yields

Version             : 0.53.0
Install location    : C:\Users\Work\.dotnet\tools\.store\dotnet-script\0.53.0\dotnet-script\0.53.0\tools\netcoreapp3.1\any
Target framework    : netcoreapp3.1
.NET Core version   : 3.1.5
Platform identifier : win
Runtime identifier  : win10-x64

and dotnet script --debug publish .\delete_empty_lochistory_entries.csx results in

info: Dotnet.Script.Core.ScriptCompiler[0]
      Current runtime is 'win'.
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      Creating project file for C:\sources-work\FamillityApi\scripts\.\delete_empty_lochistory_entries.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptParser[0]
      Parsing C:\sources-work\FamillityApi\scripts\.\delete_empty_lochistory_entries.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      Project file saved to C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\script.csproj
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      <?xml version="1.0" encoding="utf-8"?>
      <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
          <OutputType>Exe</OutputType>
          <TargetFramework>netcoreapp3.1</TargetFramework>
          <LangVersion>latest</LangVersion>
        </PropertyGroup>
        <ItemGroup>
          <PackageReference Include="Dapper" Version="2.0.35" />
          <PackageReference Include="MySqlConnector" Version="1.0.0" />
        </ItemGroup>
        <Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
          <WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
        </Target>
      </Project>
dbug: Dotnet.Script.DependencyModel.Context.CachedRestorer[0]
      Skipping restore. C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\script.csproj and C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\script.csproj.cache are identical.
dbug: Dotnet.Script.DependencyModel.Context.ProfiledRestorer[0]
      Restoring C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\script.csproj took 2ms
dbug: Dotnet.Script.Core.ScriptCompiler[0]
      Configuration/Optimization mode: Debug
dbug: Dotnet.Script.Core.ScriptCompiler[0]
      Suppressed diagnostic CS1702: warning CS1702: Assuming assembly reference 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'MySqlConnector' matches identity 'System.Data.Common, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Data.Common', you may need to supply runtime policy
dbug: Dotnet.Script.Core.ScriptCompiler[0]
      Suppressed diagnostic CS1702: warning CS1702: Assuming assembly reference 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'MySqlConnector' matches identity 'System.Data.Common, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Data.Common', you may need to supply runtime policy
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Executing 'dotnet publish "C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\.\netcoreapp3.1\delete_empty_lochistory_entries.csproj" -c Release -r win10-x64 -o "C:\sources-work\FamillityApi\scripts\.\publish\win10-x64" /p:PublishSingleFile=true /p:DebugType=Embedded'
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Copyright (C) Microsoft Corporation. All rights reserved.
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
        Determining projects to restore...
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
        All projects are up-to-date for restore.
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      c:\program files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      c:\program files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis.Scripting" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      c:\program files\dotnet\sdk\3.1.301\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3277: Found conflicts between different versions of "System.Buffers" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(13,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(14,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(16,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      obj\Release\netcoreapp3.1\win10-x64\delete_empty_lochistory_entries.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [C:\Users\Work\AppData\Local\Temp\dotnet-script\C\sources-work\FamillityApi\scripts\netcoreapp3.1\delete_empty_lochistory_entries.csproj]
System.Exception: dotnet publish failed with result '1'
   at Dotnet.Script.Core.ScriptPublisher.CreateExecutable[TReturn,THost](ScriptContext context, LogFactory logFactory, String runtimeIdentifier, String executableFileName) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\ScriptPublisher.cs:line 98
   at Dotnet.Script.Core.Commands.PublishCommand.Execute(PublishCommandOptions options) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\Commands\PublishCommand.cs:line 45
   at Dotnet.Script.Program.<>c__DisplayClass4_4.<Wain>b__14() in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 180
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.cs:line 611
   at Dotnet.Script.Program.Wain(String[] args) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 251
   at Dotnet.Script.Program.Main(String[] args) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 27

I have the same problem. my dotnet script --info :

Version             : 1.2.1
Install location    : C:\Users\Administrator\.dotnet\tools\.store\dotnet-script\1.2.1\dotnet-script\1.2.1\tools\net5.0\any
Target framework    : net5.0
.NET Core version   : 5.0.11
Platform identifier : win
Runtime identifier  : win10-x64
FCUnlimited commented 2 years ago

Maybe helps: The same happened to me after reading this issue *~* I tried to delete the "publish" folder. This was not working at vscode. So I did it with the explorer. After deleting the folder I could publish again.

pleonex commented 2 years ago

In my case it happened by having the script in the root folder opened with VS Code. After moving the script into a subfolder, it was working again. My guess is that there is a conflict with Omnisharp when the script is in the top level directory of VS Code.

EmilyGraceSeville7cf commented 7 months ago

Are there any updates to this issue? 🌝