Where does WiX cache path names? - c#

Following on from my issues with a simple Visual Studio Installer Package, I'm making the switch to WiX. The learning curve is annoying, because once I've set this up I'm going to forget how it works before I need to do it again next project. But anyway, here we go.
My environment is Visual Studio 2019 and Azure DevOps (the full TFVC). The projects involved are class libraries and a WPF application all written in C#. I also have the WiXWax extension thingy to give me a GUI for adding projects and dependencies quickly.
When I created my WiX project I stupidly included a typo in the name of the project and consequently in the underlying folders. When I noticed this I decided to fix it;
Unload the projects
Using the source control explorer, rename the folder
Using notepad, open the sln file and correcting the path to the project, and the project name
Using notepad, open the project file and correct its references to the path and project name
Rename the project files
As you can see I have changed every reference to the the incorrect spelling.
Unfortunately, Visual Studio won't load the project. I get an error telling me this:
C:(correctly spelled path that matches the file system and file names).wixproj
: error : The project file
'C:(path with a typo in it)(correctly spelled project name).wixproj'
has been moved, renamed or is not on your computer.
Now the message is partly correct, because the file it says has been moved or renamed has in fact been renamed. If I click on the error it opens the wixproj file (it's just an xml of course). This file doesn't have a self referenced location though, the only things that's close is the include to the projects which haven't changed and are correct (..<correct detals>.csproj)
I have opened every xml file including the solution files and wix project files and none of them contain the typo (Ctrl+F, case insensitive, not whole word - no results).
I have tried "Removing" the WiX project from the solution and re-adding it, but I get the same error and it doesn't add it to the solution file.
What is remembering the old path name, and how can I make it forget it?
edit: I've also tried Ctrl+Shift+F per Klaus' suggestion and it finds no references.

Related

wpf string files not found on release version but work in debug c#

I have finished a very basic application (wpf/c#). The solution is made of 3 projects:
The main project for the app
The Class Library Project to store app resources (images and txt files)
The Setup project which I use to create exe file for distribution to other
machines.
While the project works fine in debug mode when I deploy it using the Setup project and install on the computer I can access the image files from the Library Project (I can see there is a dll file for the library project in the application folder) but it fails to access the text files, complaining the path was not found. This is my very first time I completed the application and attempted to deploy it so am a bit at a loss why the setup does not provide correct references to the text files and yet it seems to work fine with image files which are located in the same library project.
Can someone point me in the right direction where to look at it to troubleshoot?
I have cleaned and rebuilt all projects in the solution. retested in debug mode (works fine). tried to search msdn and StackOverflow but I cannot find any guidance I could use or follow.
I would like to be able to display text from the text files in the released/installed application version the same way it works in debug mode. At the moment it fails to find the relevant txt files.
Finally, I have managed to crack it. Posting the answer for anyone having the same problem.
The issue here was not with the file path, even though I came up with a more clearer technique of building it, see my comments above. The problem was with the way Setup Project in VS2017 was creating a package. It is handling differently images and text files, even though both are in the same Library Project, essentially for text files I had to do the following to get it working:
Open File System in Setup Project
Create the 'Resources' Folder under 'Application Folder'
Set the 'Resource' folder 'AlwaysCopy' property to 'true'
In 'Resources' folder right-click and select Add> File...
Navigate to the folder with the files and select them all (make sure the files are setup as Resources or embedded resources)
Rebuild the Setup Project
.
So summarising I had to specifically tell Visual Studio to build the folder structure in the Application Folder during the install.
Now when I run the installer the text files are included in the package and created during standalone installation. Also included a screenshot below.

What is the easiest way to make a backup in visual studio 2013?

I want to make a backup from the whole project. I also need to rename every backup. I'dont like the way to copy the project folder and rename the folder and the project file.
I've already tried to make it like that:
http://jasonfaulkner.com/VisualStudioExpressProjectBuildBackups.aspx
But it doesn't work, I am always getting the error "Invalid parameters"
Does anyone already tried this?
Thanks
The DPack extension for Visual Studio includes the Solution Backup tool that creates a zip archive of the solution and auto names it.
Manually edit .sln file
This method is entirely aimed at renaming the directory for the project, as viewed in Windows Explorer.
This method does not suffer from the problems in the Remove/add project file method below (references disappearing), but it can result in problems if your project is under source control (see notes below). This is why step 2 (backup) is so important.
1- Close Visual Studio.
2- Create a backup of your .sln file (you can always roll back).
3- Imagine you want to rename directory "Project1" to "Project2".
If not using source control, rename the folder from "Project1" to "Project2" using Windows Explorer.
4- If using source control, rename the folder from "Project1" to "Project2" using the functions supplied by source control. This preserves the history of the file. For example, with TortoiseSVN, right click on the file, select TortoiseSVN .. Rename.
5- In the .sln file, edit all instances of "Project1" to be "Project2", using a text editor like NotePad.
6- Restart Visual Studio, and everything will work as before, but with the project in a different directory.
Alse would recommend TFS, a powerfull tool to do what you pretend. You will be able even to recover previous versions of specific files,if you have any error and you have troubles find it you can see what changes you did since last "check in " etc. There are many options

How to add existing project to Visual studio 2012 after renaming the project path

I had a C# class library project as part of my solution. I later updated the root folder of the project. Since the solution was pointing to the wrong path, I had to "delete" the project and then re-add it.
However, when I add the existing project, it says "The project file \myproject.csproj' has been moved, renamed or is not on your computer".
This is baffling because the .sln file has no reference to the project. (I checked the text contents)
How does VS cache the project with it's old folder path? The solution is version controlled in TFS, but the mappings point to the new folder structure, so it's even more confusing as to where it's trying to get the old folder path from.
Edit: I checked the .csproj file, the .csproj.vspscc and none of them have a path variable in them.
I have also tried deleting the .suo file.
This has been a trouble with Visual Studio for years now. In such a case, deleting the hidden .suo file in the root folder and restart VS will reconstruct a proper .suo file and almost always eliminate the issue.
If you use TFS, take a look at Just TFS' comment in the original post to avoid this problem in the future.

How to find out where my error is coming from?

I have an annoying error that's been popping up, and I don't know where it is coming from. The error is:
Error 31 Unable to copy file "app.config" to "bin\Debug\Framework.Tests.dll.config". Could not find file 'app.config'. Framework.Tests
The problem is, I don't have a bin\Debug folder anywhere, and it does not say from where it is trying to copy app.config. Double clicking on the error doesn't bring me to any code where it is trying to copy, so that doesn't help me either. So I don't know where I should make the app.config.
How can I find this out?
You have added a reference to a file called app.config or Visual Studio did this for you. The file does not exist on the disk, presumably because after adding the reference you later deleted the file.
Search for the missing file in your Solution Explorer, and either delete the reference or create the file.
It is most likely in the root folder of one of your projects, and should have a yellow triangle warning icon showing that the file is missing.
In an MSTest project the app.config is the one that you would like to provide any calls to the ConfigurationManager class.
It resides in the root of your test project.
The bin\debug folders will be created once the project compiles for the first time. Show all files in the solution explorer should help as they are not (and should not) be included in the project.
HTH
You probably do have a bin\Debug folder beneath your project folder, being the build target folder created by Visual Studio when you build your project for the Debug configuration.
My guess is that something (a test framework perhaps) still has the DLL file loaded, so Visual Studio can't delete and replace the existing Framework.Tests.dll.config file with the contents of your app.config. [Note: the project build action for app.config files is to copy it to the target folder renamed to match the executable with an extension of .config appended.]

Why does VS2010 allow for the concept of "include in project"?

I'm still learning the basics of how VS2010 sees the world. Apparently, you can optionally "include" a file in a project. I'm a bit confused by this: If a file is version-controlled, AND the file is within the project directory, shouldn't it implicitly be "included" in the project? If not, what's the use case where a version-controlled file in the project directory should NOT be included in the project?
=== Addition ===
Based on the answers I've gotten so far, maybe I should rephrased my question: What does it mean for a file to be "included" in a project?
A project needs to know about files in order for compilation and distribution to occur. Just because you have a file that's under source-control, doesn't mean that it will be compiled if the project is unaware of it.
Also, you may want to include files as part of a distribution package. We do this quite often for our web projects that we distribute using web app gallery.
Conversely, you could have documentation or sql scripts that you version control, but do not want them to be part of the project.
EDIT: In answer to your update, what it means for a file to be included in a project is that the file is actually added to the .csproj or .vbproj file and will be used during compilation and/or distribution. VS does differentiate if the file is Content or if it needs to Compile it. This can be seen by clicking on the file in Solution Explorer and looking at the Build Action property.
No, you don't want random files that happen to be in the project directory included in source control.
We do sometimes put documentation (pdfs) or drawings/schematics in the project folder and under version control but you don't need them inside the visual studio project (especially when they are not being distributed because they are for internal use only).
Excluding the file from your project can be useful if the file is related to the project but not necessarily needed in the solution.
Example
If I need some test XML for an application that i'm writing; that is designed to normally be pulling this from a WCF service, it can be useful to keep that file in the directory for a development environment where I use IO to get the XML for testing, but I don't necessarily want it in my solution which is source controlled.
When you exclude a file from a project is no longer compiled or embedded, then when you want to include it again you can do so without having lost your settings.
If you e.g. copy a file (containing a helpful class which want to have in your project) into a folder of your project, then you will see ... nothing. You have to check the option "Show all files" of the solution explorer and the copied file can be seen, but it is still "greyed out". No you can choose the menuitem Include in project and that file will be integrated in your project and a pending change (add) for your source control is added too. Visual Studio doesn't include all files it can find in the project folder automatically to the project - and that is a good feature.
One of my colleagues explained to me a scenario in which a version-controlled file should NOT be part of the project. Here's the idea:
A developer writes some new code.
The code is experimental, and not intended to be part of the normal build.
The easiest way to exclude the file from the build is to NOT include it in the project, but still version-control it.
This way, the file can be shared with other developers, but not break the build.

Categories

Resources