How do you make sure files from a project get included in the application directory created by an installer?
Or to put it another way: How do you include file dependencies in a setup project?
I have a DLL in my VB.NET (2010) project: TwinCAT.Ads.dll [has include] that has its own dependency: TcAds.dll [has no include anywhere in my project], which is Not a .NET assembly.
I got the compiler to make sure it spits TcAds.dll into the bin output folder when compiling by adding it as an existing item to my project, then setting it's build action to "Embedded Resource" and setting it to copy always to Output Directory.
Now that I'm ready to publish, I've made a windows setup project.
Please, no suggestions to use WIX or whatever, this is what I've got to work with.
The problem is that this outcast of a DLL does not appear as a dependency and therefore doesn't get included in the installer. After install, program runs, can't find DLL, bombs out.
I've tried adding it as a resource to the project to no avail. (project - properties - resources)
Cannot set it's build action to compile (It gives error "unable to open module file...")
Build action "Resource" doesn't even get it included in the bin folder, let alone the installer
Adding it as a reference does NOT work (It gives error "A reference to ... could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.")
Surely there must be a simple way to ensure whatever file you want gets included in the install directory?
You can add an arbitrary file to your setup project.
I created a setup project and added c++ ddl file to output. It has a following section in setup project file. You can easily add your dll file to your project in this way. If you need you can write post-build script to copy this file to suitable location so that setup project will find it.
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_06335985DF0F4EF3A600861437AA6CDF"
{
"SourcePath" = "8:..\\Debug\\CppWin32.dll"
"TargetName" = "8:CppWin32.dll"
"Tag" = "8:"
"Folder" = "8:_1E4113F2F81040508FD1CDA54F242F25"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
}
see my build output.
------ Build started: Project: ConsoleApplication1, Configuration: Debug x86 ------
ConsoleApplication1 -> P:\denemeler\setupDeneme\Setup1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
------ Starting pre-build validation for project 'Setup1' ------
------ Pre-build validation for project 'Setup1' completed ------
------ Build started: Project: Setup1, Configuration: Debug ------
Building file 'P:\denemeler\setupDeneme\Setup1\Setup1\Debug\Setup1.msi'...
Packaging file 'CppWin32.dll'...
Packaging file 'ConsoleApplication1.exe'...
========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped ==========
Related
I created a project folder (test1), then when creating the C++ source file main.cpp, it says that this file is not part of any project although i created it in the same project test1 by doing :
File -> new file or project -> C++ -> C++ source file.
Open the .pro file and check if something like this is missing:
SOURCES += main.cpp
(with proper path if needed)
Also it seems you did not configure the project. In "projects" you should choose a kit to use when building. This may also be a cause of the warning.
For a .creator project (without Qmake) deleting the .creator.user file while Qt Creator is closed helped in my case.
I'm getting this error when running a built project in Visual Studio 2017:
------ Deploy started: Project: myProj, Configuration: Debug Win32 ------
C:\...\myProj.vcxproj : error MSB4057: The target "Deploy" does not exist in the project.
Done building project "myProj.vcxproj" -- FAILED.
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
I found something online saying uncheck Deploy from Build, Configuration Manager... but it is already unchecked.
If I try to run it again, it will load and run. But I'd like to be able to release code that works the first time. What else might I try? TIA.
Odds are you have a post build event in your project. When you first build it the post build event fires and attempts the deploy. The second time you go to build the project is already 'up to date' so it is not built and the post build event does not fire.
You can view your post build events by right clicking your project and choosing properties, expanding build events and then expanding post build.
You can also check if anything is defined under custom build steps.
Solved the problem by opening the .sln file of the problematic solution with a text editor. I've found there the following lines for different configurations:
{GUID}.Release|x86.Deploy.0 = Release|Win32
After deleting all these lines for different configurations, I didn't get the error anymore.
This worked for me :
GOTO "Project Property Page"
click "Project Dependencies"
Select your main project in "Project:"
Add the dependency on the project that gives you the deploy error.
Save ALL
Recompile
After some changes to my project, Visual Studio started to always re-compiles all sources, causing all dependent project to also re-compile, slowing down development considerably. Why is that?
Happens only when XML documentation file is checked and there's some file with Copy always. If you change either of these, the sources don't get re-compiled.
Happens only when compiling inside Visual Studio - when compiling using MSBuild from commandline, the sources don't get re-compiled.
Visual Studio 2012 Update 4.
This appears to be a bug in Visual Studio, when project has XML documentation file checked some files with Copy always.
Repro:
Create new project - C# class library.
Project Properties => Build => check XML documentation file
Project => Add => New Item => Text file TextFile1.txt
Change TextFile1.txt Copy to Output Directory to Copy always
Right-click project => build
project compiles
Right-click project => build
Expected: Project shouldn't be built, build output should say:
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
Actual: Project is build, output is:
------ Build started: Project: ClassLibrary1, Configuration: Debug Any CPU ------
ClassLibrary1 -> bin\Debug\ClassLibrary1.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Intestigation: Turning on detailed log, you see:
Target "CoreCompile" in file "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets" from project "ClassLibrary1.csproj" (target "Compile" depends on it):
Building target "CoreCompile" completely.
Output file "bin\Debug\ClassLibrary1.XML" does not exist.
Looking in procmon, you see that devenv.exe renames "ClassLibrary1.XML" into "vsA381.tmp" just before MSBuild.exe runs. Stack trace for the rename:
KERNEL32!MoveFileW+0x17
csproj!CMoveOutOfTheWayScope::EnterScope+0x85
csproj!CVsProjBuildableProjectCfg::StartBuildProcessWithTarget+0x50b
csproj!CVsProjBuildableProjectCfg::StartBuildProcess+0xc
csproj!CVsProjBuildableProjectCfg::StartBuildEx+0x15
msenv!CSUIBuilder::DoBuild+0x1a3
msenv!CSUIBuilder::Run+0x66
I've added an unamanaged dll in project OldTesters using Add Existing File.
I've also set BuildAction = Content and Copy to Output Directory = Copy if newer.
I'm using some functions from unmanaged dll in OldTesters project via [DllImport("unamanged.dll")]
OldTesters is .NET project that I've referenced in my main project using Add Reference.
The problem is when I rebuild application everything works fine, but then I close app,
and then click on start, it throws me DllNotFoundException
Unable to load DLL 'unmanaged.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I've noticed that Visual Studio deleted unmanaged.dll from bin directory.
If I rebuild OldTesters project then it will work. But it is annoying always to rebuild OldTesters, cause I do not add any changes in that project. To prove that, if I click on Build, I will get:
========== Build: 0 succeeded, 0 failed, 6 up-to-date, 0 skipped ==========
because there are no changes in the project.When I run the app I get the same exception.
Although this is VERY old, I just stumbled across the same problem and found the following solution:
just copy all the dlls that are "deleted" to your current project in VS, then they are copied whenever this project is created.
So in your case you just open the project OldTesters, click on the unmanaged dll, copy and then paste it into the project that your other project.
I have a visual studio solution with a number of projects.
Configuration manager is carefully configured to build all projects except one ( the one skipped is a test project ). After building solution in command-line i got following:
"building XXX Debug|x64"
------ Skipped Build: Project: AAA ------
------ Skipped Build: Project: BBB, Configuration: Debug Win32 ------
Project not selected to build for this solution configuration
------ Build started: Project: CCC, Configuration: YYY Debug ia64 ------
< here goes build >
As you can see, project BBB is skipped becouse it is not selected in configuration manager, project CCC and rest build ok and project AAA is skipped with NO REASON GIVEN. Anyone knows why visual studio may skip project build without any reason? All configuration names ( XXX, YYY Debug, Debug ) and platforms ( x64 / Win32 / ia64 ) are correctly configured in configuration manager.
Is project AAA selected for configuration Debug|x64 ?
Also I had the same situation when freshly downloaded solution (without .soa file) had the default configuration to Itanium, so all system without its support were skipping all solution projects to build. Properly build was starting only after selecting win32 manually.
Run the project from the command line using MSBUILD.exe and set the parameter for logging (verbosity) = detailed or diagnostic. You should then get me more output telling you why msbuild considered skipping the one in question. e.g.
msbuild XXXX.csproj /verbosity:detailed
Nb. Diagnostic output is very very verbose
Normal builds within Visual Studio are incremental: Visual Studio will skip building a project if it thinks none of the source files have been changed - note that it only checks code files, not resources or other "stuff".
Try doing a clean build by selecting Build|Clean Solution then Build|Rebuild Solution and see if you get the same results.
You may need to manually clean up the build artifacts for each project (by default, the \Bin\ and \Obj\ subdirectories within each project directory).