EXEs does not copy on build in visual studio - vb.net

I have a VB.NET solution containing multiple projects and the expected result is the EXEs in one project should be copied to bin folder of other projects on build. While rebuild solution does this, build solution does not copy the EXEs and even deletes the previously copied EXEs.
Any idea why this is happening?
Thanks

There provides two method which may help you solve your problem:
1.Renaming the executable file
2.Another method:
Closing Visual Studio
Deleting the bin and obj folders
Reopening Visual Studio.

Related

How reimport .targets file in Visual Studio?

I work in Visual Studio. It seems for me, that, if I change anything in imported .targets file, the new version of .targets is not reimported to main project while building it. If I reopen my project (I.e. close and open again Visual Studio) and then launch build - the new version of .targets works.
Is it possible to tell Visual Studio to import .targets at any rebuild?
I tried use "rebuild" and "clean" solution and project, without any result regarding the problem.
Re-evaluating imported files is done by the new CPS-based project systems that are used for .NET Core / .NET Standard projects.
For VS versions before VS 2019, you may also need to indicate to MSBuild that the imported targets file should also re-trigger incremental build by adding its path to $(MSBuildAllProjects) (this is no longer needed in MSBuild 16 / VS 2019):
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
But for "classic" .NET Framework / ASP.NET projects, you still need to close and re-open the solution for changes to take effect inside the IDE.
Also see this GitHub tracking issue for the legacy project system.

Add a dependency / reference to your own DLL project in Visual Studio 2013

I have been working on a few different applications and I want them all to share the same DLL library. The shared DLL is one that I created, so really I want each application to have a dependency on the DLL so that the DLL gets built in the same solution as the application. Then the DLL should copy itself to the application's bin folder before the application runs.
After figuring out how to do this, it seems that it should have only taken about 5 minutes, but unfortunately it took me an hour to figure out. That's partly because similar questions were referring to older versions of Visual Studio, or referring to 3rd party DLLs. So I thought I'd post the steps here.
You should already have one existing project and solution for your DLL. Open your solution for your new application that depends on your DLL
Highlight the top line in your Solution Explorer (your solution name), then go to the File menu and choose Add > Existing Project...
Browse to the project file for your DLL and select it. That will add the DLL project to your solution
Although your projects are now in the same solution, that didn't actually create a reference for your main project. So now right-click on your original project (should be 2nd line in your Solution Explorer) and choose Add > Reference...
The Reference Manager will appear. Be sure that you have Solution > Projects selected on the left. Then you should see your DLL project listed on the right. When you hover over it, a checkbox will appear. Select the check box. Click OK.
Last, be sure that your Project Dependencies are set correctly. Again, right-click on your Solution in Solution Explorer (top line). Choose Project Dependencies...
In the Projects drop down, make sure your main project is selected. Then in the Depends On list below, check the box for your DLL project.
Now when you Build your solution, it will first build the DLL, then copy it to your applications bin folder, then build your application. The Reference will also allow you to refer to the DLL in your code files, for example with "using MyLib;" for C#, or "Imports MyLib" for VB
Now when you Build your solution, it will first build the DLL, then copy it to your applications bin folder, then build your application.
Thank you for explaining this. I did all the steps (Visual Studio 2015) and I noticed that "Build solution" command builds all the DLLs, but it does not copy them to the right bin folder. To achieve that I need to build the active project (right-click on the active project, then "Build").

Loading 3rd party dlls for common use in Visual Studio 2012, C++

I have glut32.dll file which needs to be in the Debug folder whenever I compile a source. It's very frustrating to manually put in the Debug folder of each project file to have it run properly.
Is it possible I can put it in some folder and point the project to it?
I am a newbie with Visual Studio 2012.
Before this question being tagged as a duplicate, I want to add I keep seeing suggestions Referencing third party dlls, but I couldn't get it.
Any help appreciated !
If you add a project reference to this DLL, I believe it should be copied to the Debug folder automatically.

Visual Studio won't find references

I'm working with some application handed over by another person in which I must document the requirements, build and deploy processes.
The problem here is that Visual Studio (2005) is throwing a lot of errors since it can't find the references for the dlls.
This obviously won't let VS build the project.
Everything works fine on the persons computer but not on mine, even though the project references the same folder where the dlls are, the bin folder.
How can I circumvent these problems and get VS to properly reference the dlls?
The following printscreen shows the references screen for the project.
My guess is that your DLL uses a more recent .NET framework than your application does.
Check the properties for your DLL source (right-click on the DLL code in the solution explorer and choose Properties). Go to Application - Target .NET framework and compare the version to the one the application itself uses (right-click on the project code). Note: under your application properties check both the settings under Application - Target .NET framework AND under Publish - Prerequisites.
For what it's worth, even after changing the .vbproj file and removing many lines about hard coded values,
I eventually checked out the project again removed all references to the given DLL and then added it using the GUI.
Lesson learned, don't try to change out one DLL for a newer version without using VB2005 GUI.
The easiest solution will probably be to transfer everything to another project. It will be incredibly time consuming to find where visual studio has left the hard coded path at.
WOOT!!!! Compile the DLL file to a lower version of the .NET framework, and it will fix the problem!!!!
The paths in the project file cannot be the same or the assemblies referenced have a different version.
It might be worth unloading your project and the editing it to inspect where it's looking and for what version.
I had the same problem with an older Visual Studio Project that I opened in Visual Studio 2008. I tried to add new references to the project and got permanent errors that the dll's cannot be found. After the migration of the Project to Visual Studio 2010 I got the following error message when I tried to add a new reference:
'mySample.dll' or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project. You can change ...
After changing the projects .NET Framework to a newer version everything works fine.
Good suggestions in other answers. In my case, it was because the libraries weren't copied (downloaded) successfully: the files existed, but were 0 kB.
Did a clean, which removed all the DLL's and then VS2008 complained it couldn't find the references (Duh!!!) and wouldn't rebuild....luckily I had and old version of the dll's and replaced them in the directory AND THEN did a rebuild to replace them...all references are now OK and we're back to normal....good old VS 2008

WCF compilation error on CI server: Microsoft.VisualStudio.ServiceModel.targets not found

I am getting this error on my CI server:
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" was not found
It seems my WCF service library project references that file, but the VisualStudio folder on Program Files\MSBuild\Microsoft doesn't contain a WCF folder.
I guess I need to install something on the server.
What do I need to install?
Well this ruined my morning, but let's not allow it to ruin anyone else's. I couldn't find this information anywhere else. You need to copy a few files from a development machine with VS Pro 2012.
As aphexddb mentions, you need to copy some targets from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF to the same location on your CI server.
This then references an assembly called Microsoft.VisualStudio.ServiceModel.Core. You can find this assembly in either the GAC or in the IDE directory at C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE.
Copy this to your CI server and execute gacutil.exe -i Microsoft.VisualStudio.ServiceModel.Core.dll
This was enough to fix it for me.
This isn't the first time I found targets missing from my VS express install in my CI server. I can't help but feel that there is some sort of package I can download from somewhere that fills all this in. Does anyone know of such a thing? If not, perhaps we should create one.
Can still happen on vs2019
error MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\WCF\Microsoft.VisualStudio.ServiceModel.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
WCF is not installed by default as part of 'ASP.NET and web development' workload. To fix this,
On visual studio installer > modify > individual components tab, search for wcf, check, modify - the .targets file gets now installed, msbuild builds ok.
MSBuild auto-detection: using msbuild version '16.3.2.50909' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin'
I ran into this with Visual Studio 2017, for me the resolution was to modify my installation of Visual Studio to include the Windows Communication Foundation components.
Extract this file into folder
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF
The file name is "Microsoft.VisualStudio.ServiceModel.targets"
Now you can solve the problem using the Nuget Package MSBuild.Microsoft.VisualStudio.Web.targets
so the build process does not require any change to the build server.
Install-Package MSBuild.Microsoft.VisualStudio.Web.targets
Details:
remove the element for "ServiceModels.targets" in the .csproj file
remove the target WebApplication from the build command (in yaml)
Ran into this same issue. Did the following to resolve:
Installed the Microsoft Web Platform Installer
Copied Directory "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF" from dev laptop with Visual Studio 2012 to the build server
I've had the same error - my issue was that MS has modified the way MSBuild looks for the versions of VS in the build process template.
Make sure to use the right build process template.
If using TFS2013 and VS2013 use TfvcTemplate.12.xaml
I ran into this same error. In my case, the problem was that my Visual Studio 2008 project didn't get upgraded correctly, probably due to files being marked "read-only" by my source control. To fix it, I loaded the solution in Visual Studio 2015 with everything checked out.
The specific line in the .csproj file changed from
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" />
To
<Import Project="$(WcfServiceModelTargetPath)\Microsoft.VisualStudio.ServiceModel.targets" />
If you are using VS 2022 build tools, it is no longer in the individual components section. It is on the first tab "Workloads", included in ".NET desktop build tools", you will see it in the list on the right-hand side when you select it.