Visual Studio "Unable to copy file" during publishing - c#

I keep getting this error during the publishing of my VS 2019 C# win forms project
Unable to copy file "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.TextManager.Interop.8.0.dll" to "bin\Debug\app.publish\Application Files\Database Client_2_0_0_47\Microsoft.VisualStudio.TextManager.Interop.8.0.dll". Could not find a part of the path 'bin\Debug\app.publish\Application Files\Database Client_2_0_0_47\Microsoft.VisualStudio.TextManager.Interop.8.0.dll'. Database Client
This also happens with 4 other DLL's with some being from VS 2019 itself and some from NuGet packages
This has only started happening recently so I'm unsure whether this is an issue with VS 2019 as no fundamental code has been changed and the only thing that has is some logos on a few .rdlc documents (Microsoft Report Viewer).
I'm running VS 2019 Community on version 16.11.4 with only .Net Desktop development, Office/Sharepoint development and a few individual packages installed.
I've looked around and can only seem to find people having issues with the .exes themselves due to them still being open however this is not the case for me as I have checked and there are no background processes like devenv.
What's strange is both the Debug and Release build fine with no issues whatsoever.
I've also tried deleting the \bin and \obj folders to no avail.
Below are some images of my settings that involve publishing
Publishing Main Settings
Prerequisites
Deployment

It seems the solution to this problem, as #HansPassant commented, was to shorten the build path as it was exceeding the MAX_PATH variable.
Once my project was moved from the default C:\Users\Drew\source\repos\ to just the C:\ drive my project was able to publish successfully.

Related

Set toolpath to MSBuild 2019 in a TFS 2013 using (XALM) build process templates

TL;DR: Clean Windows build server, MS Build Tools 2019 and TFS 2013 installed.
Build Logs says Exception Message: File not found: MSBuild.exe (type FileNotFoundException)
How Do I setup MSBUILD toolpath in a XAML file on TFS 2013, configured to use MSBuild 2019 with a Visual Studio 2019 Enterprise installed on my dev box.
Please provide FULL XAML file that WORKS with TFS2013 (update 3) with an explicit custom msbuild path.
A Bit more info:
We have a multi server setup for our TFS build routines running version 2013.
One controller and a few agent servers here and there, nothing fancy.
Recently I added yet another for GUI Testing - I need the agent service to be in Interactive mode.
Steps so far:
Installed TFS 2013 including two agents - linking to the main controller.
I install Build Tools version 2019
I added tags to control the build destribution.
Activated a build and the rest is history.
I'm four (frustrating) days in on this - I've read every Stack Overflow TFS set toolpath entry I can find, and a huge bunch of odd forums, yet none seems to scratch my itch here.
I even added both paths you see further down, to the Windows environment PATH variable. Im not sure that does anything anymore.
See; Everybody talks about this entry in the XAML that says toolpath (or similar) - but; I dont see it. We use a minor changed version of a TfvcTemplate.12.Xaml.
Many also talk about this GUI tool for editing XALM files, where I get to see all the different options available (I presume) - can someone help me with this too? Its certainly not working out of the box with a 2019 Enterprise????
So; I installed this Extension Process Template Editor, but of course nothing happens when I click a XAML file, just more XML :)
I now have a few added paths on the new server, where I see instances of msbuild.exe installed (MS/.NET get your act together, please)
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
C:\Program Files (x86)\MSBuild\12.0\Bin
Please try not to write this off as a duplicate at first glance. I know its similar to other questions - however; Devil is in the details.
Set toolpath to MSBuild 2019 in a TFS 2013 using (XALM) build process templates
Just as you know, the Old Visual Studio versions installed msbuild into C:\Program Files (x86)\MSBuild\<version>\bin and apparently the RunMSBuild activity used the ToolVersion + the ToolArchitecture to calculate this path.
VS 2019 build tool instead installs it C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin and the RunMSBuild can't calculate the proper path anymore. You can not use the old DefaultTemplate12.xaml to integrate with VS2019 build tool.
To make this work, you could try to modify the TFSBuildServiceHost.exe.config and you must have a version of VS 2019 build tool or VS2019 installed on the build server in order for this to work.
More detail step please follow Jonesy2488's answer in this link:How to get VS 2017 working with TFS 2017 XAML Builds.
Besides, we could also try to use MSBuild task instead of Visual Studio Build task, then specify the location of MSBuild 16.0:
Hope this helps.
I made it work by changing ToolVersion for mtba:RunMSBuild in TfvcTemplate.12.xaml to the required version and adding MSBuildToolsPath to Windows Registry.
Registry settings for 15.0 and 16.0
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\15.0]
"MSBuildToolsPath"="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\amd64"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\16.0]
"MSBuildToolsPath"="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\amd64"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\15.0]
"MSBuildToolsPath"="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\16.0]
"MSBuildToolsPath"="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin"

Trying to run an Azure Function App locally from Visual Studio 2017 gives a 'func.exe does not exist' error

I have created a new Azure Function app with an Http Trigger in Visual Studio 2017 (which I have just updated to v15.8.4).
Using the generated function, when I try to run it I just get a message box with the error
The debug executable "C:\Users\Paul\AppData\Local\AzureFunctionTools\Releases\2.5.2\cli\func.exe" specified in the 'FunctionApp1' debug profile does not exist.
Sure enough there is no func.exe at that location, just a func.dll.
The file C:\Users\Paul\AppData\Local\AzureFunctionTools\Releases\1.3.0\cli\func.exe does exist.
I have successfully run an Azure function locally before but I assume updating Visual Studio a few times has broken something.
How can I get this working?
I Deleted AzureFunctionsTools and azure-functions-core-tools from C:\Users\ {YourUser} \AppData\Local. And ran the solution again it downloaded the same tools and then executed without errors.
I eventually got this to work by changing the settings in the Debug screen.
I changed Launch from Project to Executable
I set Executable to C:\Users\xxxx\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.exe
I changed Application arguments to start
I changed Working Directory to Sourcedirectory\FunctionApp1\FunctionApp1\bin\Debug\netstandard2.0
I would still love to know where the Project settings were getting their values from though...
In my similar case after installing Visual studio 2019 16.11.2 in a new Win 10 S.
I had already AzureFunctionsTools version 3.23.5 installed with func.exe inside the cli folder (without_x64 suffix)
But my newly installed VS 2019 was looking for func.exe in a similar path with only one difference that was (_x64 suffix after cli).
C:\Users\[username]\AppData\Local\AzureFunctionsTools\Releases\3.23.5\cli_x64
After getting no result trying a other solutions mentioned here I finally renamed the existing cli folder to cli_X64 and it worked
How can I get this working?
In your case, it seems that there is no azure function tools v2 , please have a try to install it.
npm i -g azure-functions-core-tools#core --unsafe-perm true
Please also try to update the [Azure functions and Web Jobs tools] to latest version
tool->Extensions and updates
And then try to run the azure function, if there is no corrosponding version it will download it automatically.
Test Result
Update
Check the function tools from the path
C:\Users\{userName}\AppData\Local\AzureFunctionsTools\Releases
I am able to get this working just by targeting .Net Standard 2.0.
Just change to netstandard2.0 in the project file.
Application Settings
Debug Settings
There is no need of providing a path to the func.dll.
I was just having on a fresh install of Visual Studio 2019 (had to uninstall 2017), and it was irritating me to no end.
I have found a solution to the problem, but no reason as to why this problem happened nor why Visual Studio deemed it necessary to make it so hard to fix things (they have no option of installing or reinstalling Azure Functions Tools in VS 2019 or even outside of it).
Solution:
Find a way to download the release. I used npm: npm install -g azure-functions-core-tools#3
(-g is global but you can install it locally, #3 will install the latest 3.x.x)
Replace the entire contents of C:\Users\<username>\AppData\Local\AzureFunctionsTools\Releases\3.4.1\cli_x64 with the version you installed.
For me, it was all the files in \node_modules\azure-functions-core-tools\bin.
What worked for me is combination of above two answers .
Same error I also faced due to anti-virus but can't modify anti-virus since it can be changed by IT Security/networking team and process is time-taking & long process. Another workaround is :
Install azure-functions-core-tools via npm
npm install -g azure-functions-core-tools#3
Change Executable & Working Directory in Debug settings for azure Project settings
Working Directory : C:\<Project path>\bin\Debug\netcoreapp3.1
Executable : C:\Users\<username>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.exe

Visual Studio 2017 fails to install offline with "Unable to download installation files"

So I've created an offline installed of VS 2017 Community on my laptop using this command:
vs_community.exe --layout "D:\Downloads\VS Community 2017" --lang en-US --add Microsoft.VisualStudio.Component.CoreEditor Component.WebSocket Microsoft.VisualStudio.Workload.ManagedDesktop Microsoft.VisualStudio.Workload.NetCrossPlat Microsoft.VisualStudio.Workload.NetCoreTools Microsoft.VisualStudio.Workload.Node Microsoft.VisualStudio.Component.TypeScript.2.0
When I transfer the setup files onto my corporate PC (which is behind a firewall) and run the "vs_community.exe" setup file, all I get is this error. There's no way to bypass the corporate firewall or to make exceptions. How do I install VS 2017 offline? Am I missing something here?
Edit: I have installed VS 2017 on my laptop keeping the internet connection active. Then when I disconnect the internet on my laptop and try installing again, the installer launches! So perhaps there are some dependencies missing on my corporate PC that are now installed on my laptop?
Edit: The above command installs .NET, .NET core, Xamarin, Node.js, TypeScript and C++ for Mobile. The total downloaded size is 13.2 GB.
It worked!! All I had to do was install the certificates into the root CA! Something I missed noticing in the VS 2017 docs:
How to install from the offline installation folder
Install the certificates (They are in the "certificates" folder, which is in your Layout folder. )
Simply right-click each one and choose Install PFX.
Specify Local machine (not current user)
You can use an empty password
Run the installation file. For example, run:
c:\vs2017offline\vs_enterprise.exe
--- Microsoft Docs
Edit: Remember to install the certs using the Admin account on the PC, or it won't work...
Please try to follow this steps:
Right click on exe file.
Select "Properties".
Click on the "Digital Signatures" tab. Now you can see "signature list".
Select signature
Click on "Details" button.
Click on "View certificate" button
Click on "Install certificate" and follows installation wizard
All certificates within "signature list" should be installed. I use Windows 10.
Was doing this for VS Community 2017 and it would install everything and it does the core installation without any trouble. However, if i select to install the universal or .Net development portions it will install it almost completely, but it will fail on two files. It will say that it cannot download the files from the internet. The files exist in the installation directory and I even went and downloaded the files and placed them into the appropriate directories and it still thinks that it needs to download those two files preventing me from completing the installation process. If I just continue it will install everything else except those two files. I've tried this with a few different layout downloads in different forms (ISO, directory, etc) and same issue (so it isn't a bad download or anything, and I'm sure I did that all correctly). The two files are:
https://download.visualstudio.microsoft.com/download/pr/10983757/f8c877406947fdc71ed2dd9127d2f9fa/microsoft.codeanalysis.visualstudio.interactivecomponents.resources.vsix
https://download.visualstudio.microsoft.com/download/pr/11347028/25bedee219940beceecab91dac231235/microsoft.visualstudio.testtools.testplatform.legacy.core.resources.vsix
If I plug myself online and do a repair it will go grab those two files without having to grab everything else, but it kind of defeats the purpose. Don't expect a solution, but wanted to mention it because all the other problems are related to installing the certs and I can't find anything online about it failing on just a few files.
In my case it was related to CNG key isolation windows service, it was disabled, the solution mentioned in below link:
Visual Studio 2017 - Can't install
How i solved mine.
I downloaded the setup helper from Microsoft website (i downloaded the enterprise installer, because that's the offline installer version i have )
I ran the program, and it wanted to download the complete setup, so i cancelled it
I ran my offline installer (vs_Enterprise.exe)
Then it fixed the issue.
I disconnected the internet, and continued with the offline installation
I have the same issue after uninstalling SSDT for Visual studio 2017, Can't remove and reinstall or update visual studio 2017.
I just restart my machine and it's OK.
my be you have also to log in as an administrator ( it depends on your machine configuration and what you can do with you current account)
Edited to avoid misunderstand
Running the downloaded Visual Studio layout as administrator worked for me.
Maybe the VS_Version.exe try to normally download the files because it can't access to files in the layout (sometimes named backup), like me, in my job we have a lot of restrictions and when I ran the VS_version.exe tried to download and get the message error, but when I ran again the .exe as Administrator the installer started normaly, getting the files from the backup folder

Metadata file 'System.EnterpriseServices.Wrapper.dll' could not be opened -- 'Error importing module 'System.EnterpriseServices.Wrapper.dll'

OS: Windows 8.1
Visual Studio Premium 2013
I have a complex MVC application that I have been running for years. I am able to run the application in debug without issues. However, just this afternoon, when I tried to publish the application for deployment I receive this error:
Error 8 Metadata file 'f:\Documents\Visual Studio 2013\GIT\Maloha\site\bin\System.EnterpriseServices.dll' could not be opened -- 'Error importing module 'System.EnterpriseServices.Wrapper.dll' of assembly 'f:\Documents\Visual Studio 2013\GIT\Maloha\site\bin\System.EnterpriseServices.dll' -- The system cannot find the file specified. ' F:\Documents\Visual Studio 2013\GIT\Maloha\site\CSC site
I have restarted my computer.
I have tried to clean and rebuild the application.
What would cause this to suddenly appear? How do I fix it? I need to be able to publish the application.
UPDATE
I uninstalled .NET 3.5 and reinstalled it. I can now see the file in the specified folder, but I still get the error.
I had a similar issue. I have no idea if my solution will work for you, but here is what someone told me to do:
Delete the files from the bin folder so they can be rebuilt with the next publication.
I have no idea why it worked, but I was able to use the solution after that.
Unfortunately, I can't provide any additional insights or directions beyond this.
Clean the project or delete the files from bin folder and then rebuild it again, it happened with me twice and that was the solution which solved my problem

Deploying Click once on production environment

This is strange but I was not able to find a simple guide, supposedly of a trivial task.
I can publish my Click-once application on IIS through visual studio. Now I want to move the application to client side. There I don’t have visual studio.
No how do I change the server of my click once application which is hosted on my system to client system?
I was able to find many guides describing how to do it through visual studio in dev environment, but I was not able to find the guide on how to do it on production without visual studio
Any guide or steps will be very helpful
There are in principle two ways how to the create a ClickOnce publication.
Using Visual Studio publishing wizard as you do.
Using MAGE.exe or MAGEUI.exe
(in C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\). - watch out that you use the right version.
But ClickOnce application consists of 1 file and 1 folder that can be copied.
So you just publish internaly to your server, and then just copy the .application file and appropriate one folder with latest version which resides under Application Files folder. You do not need to setup any extra publishing software, I think.

Categories