Open asranja opened 3 years ago
@dsplaisted is this an sdk issue?
@BenVillalobos The issue might be in the .NET SDK, the publishing system, MSBuild, or something else.
@asranja Would it be possible for you to provide a repro project and/or a binlog of the build that does this?
Please use this for repro https://github.com/asranja/web-application. I just created an ASP.NET MVC application and added a file with Swedish characters in name.
@asanjabi Have you found a solution yet? I have the same problem.
@asanjabi Have you found a solution yet? I have the same problem.
I think you meant to tag @asranja
Investigation notes:
There are no garbled characters in the binlog anywhere. Also, looking into the obj/
folder, Pts.Master.Analys.Jämförelse.dll
looks to be generated with a proper name. When the file is copied over to bin/
it also has the proper name.
Thinking this could be an issue with the publishing system. Where is this file copied over...
I think I've narrowed it down to the VSMSDeploy
task. After a successful build using the repro steps, you can just run msbuild WebApplication4.sln /bl /t:PackageUsingManifest
and see a generated zip file with the mangled name. It comes from Microsoft.Web.Publishing.targets
, who owns that?
@BenVillalobos - Can you please pass the property UseMsDeployExe
to true
and see what it outputs? If it is passing all the right parameters to msdeploy.exe, then it could be an issue in the msdeploy tool itself. Can you share the output after passing the UseMsDeployExe to true?
@vijayrkn Running msbuild WebApplication4.sln /bl /t:PackageUsingManifest /p:UseMsDeployExe=true
This is the console output of the PackageUsingManifest
target:
PackageUsingManifest:
Packaging into C:\src\git\_customerProjects\web-application\WebApplication4\obj\Debug\Package\WebApp
lication4.zip.
Running msdeploy.exe.
C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe -source:manifest='C:\src\git\_custom
erProjects\web-application\WebApplication4\obj\Debug\Package\WebApplication4.SourceManifest.xml' -de
st:package='C:\src\git\_customerProjects\web-application\WebApplication4\obj\Debug\Package\WebApplic
ation4.zip',IncludeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtensi
on -disableLink:CertificateExtension -declareParamFile:"C:\src\git\_customerProjects\web-application
\WebApplication4\obj\Debug\Package\WebApplication4.Package.Parameters.xml" -retryAttempts=2
Info: Updating file (C:\src\git\_customerProjects\web-application\WebApplication4\obj\Debug\Package\
PackageTmp\bin\WebApplication4.dll).
Info: Updating file (C:\src\git\_customerProjects\web-application\WebApplication4\obj\Debug\Package\
PackageTmp\bin\WebApplication4.pdb).
Total changes: 2 (0 added, 0 deleted, 2 updated, 0 parameters changed, 29184 bytes copied)
Successfully execute msdeploy.exe.
Package "WebApplication4.zip" is successfully created as single file at the following location:
file:///C:/src/git/_customerProjects/web-application/WebApplication4/obj/Debug/Package
To get the instructions on how to deploy the web package please visit the following link:
https://go.microsoft.com/fwlink/?LinkId=124618
The dll in the zip folder is still borked: Pts.Master.Analys.Jämförelse.dll
Edit: Same resulting dll name if I delete the previous zip and run again.
Looks like all the params to msdeploy.exe seems correct, do you see anything wrong in the any of the xmls passed to it? If not, this will have to go to the msdeploy team
C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe -source:manifest='C:\src\git\_custom erProjects\web-application\WebApplication4\obj\Debug\Package\WebApplication4.SourceManifest.xml' -de st:package='C:\src\git\_customerProjects\web-application\WebApplication4\obj\Debug\Package\WebApplic ation4.zip',IncludeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtensi on -disableLink:CertificateExtension -declareParamFile:"C:\src\git\_customerProjects\web-application \WebApplication4\obj\Debug\Package\WebApplication4.Package.Parameters.xml" -retryAttempts=2
Looks normal to me:
WebApplication4.SourceManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<parameter name="IIS Web Application Name" description="" defaultValue="Default Web Site/WebApplication4_deploy" tags="IisApp">
<parameterEntry kind="ProviderPath" scope="IisApp" match="^C:\\src\\git\\_customerProjects\\web-application\\WebApplication4\\obj\\Debug\\Package\\PackageTmp$" />
<parameterEntry kind="ProviderPath" scope="setAcl" match="^C:\\src\\git\\_customerProjects\\web-application\\WebApplication4\\obj\\Debug\\Package\\PackageTmp$" />
</parameter>
</parameters>
@ning51 - Do you know if this is a known MSDeploy issue?
Any solution to this issue? Seems the thread died about a year ago without a solution.
I also had this problem in the past and then searched for a long time what is wrong here. I then found out that there is also a coding for Zip File.
Especially with Powershell it did this differently than when I created it with via the GUI. I then found the following zip command that works for me today.
`Add-Type -Assembly 'System.IO.Compression.FileSystem' $enc = [System.Text.Encoding]::GetEncoding(29001) #29001, x-Europa, Europa
[System.IO.Compression.ZipFile]::ExtractToDirectory($packageZipPath, $unzipPath, $enc)`
I have tested and found that it is not related to the system locale. If I use the method by @sandrosuter I can get the correct file names if I pass Encoding.UTF8
. So I can fix the file like this:
using System.IO;
using System.IO.Compression;
using System.Text;
var fs = new FileStream("publish/package.zip", FileMode.Open);
var z = new ZipArchive(fs, ZipArchiveMode.Update, false, Encoding.UTF8);
z.Dispose();
(Remember to add reference to System.IO.Compression.FileSystem
)
I am using below MSBuild command to generate a package zip for a web application which contains files with Swedish characters. The generated zip corrupts the file name.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" "C:\Users\asranja\Source\Repos\WebApplication4\WebApplication4.sln" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="C:\Users\asranja\Desktop\Package2"
[Solution]
[Unzipped package]
[Ask] What is the correct way to generate a webapp zip package which does not corrupt file names with special characters.