Visual Studio 2017 default startup project saved to file - visual-studio-2017

I have a vs2017 project, SLN file only, no SUO file. When I open the solution and go to properties its set to Currently Selected for startup project. Unless I set that manually to one of my projects, the other data migration project doesnt get the connection string when I do Update-Database. I tried re-ordering the projects in the SLN file but that didn't affect it. After changing the default project in settings though it doesnt actually update any of the source controlled files, and I dont see a SUO file. Any advice on how to modify the files of a solution to set the default startup project to a single specific project?

Startup project is deliberately saved to the .suo file, which is the user-specific settings for the solution. The .suo file has moved to .vs\SolutionName\v15\.suo instead of being right next to the .sln file.
This is to avoid cases such as where Bill, the hypothetical backend developer who only cares about an API project, and Fred, the front-end engineer who only cares about the website project, don't end up conflicting with each other's settings.
That said, the Update-Database cmdlet should take any necessary parameters to accomplish the task. In this case, it's the -StartupProjectName parameter. Note that other cmdlets may use a different parameter name.
PM> get-help update-database
NAME
Update-Database
SYNOPSIS
Applies any pending migrations to the database.
SYNTAX
Update-Database [-SourceMigration <String>] [-TargetMigration <String>] [-Script] [-Force] [-ProjectName <String>] [-StartUpProjectName <String>]
[-ConfigurationTypeName <String>] [-ConnectionStringName <String>] [-AppDomainBaseDirectory <String>] [<CommonParameters>]
Update-Database [-SourceMigration <String>] [-TargetMigration <String>] [-Script] [-Force] [-ProjectName <String>] [-StartUpProjectName <String>]
[-ConfigurationTypeName <String>] -ConnectionString <String> -ConnectionProviderName <String> [-AppDomainBaseDirectory <String>] [<CommonParameters>]

i think i have the same problem too, vs2017 don't remember the default project that i sets as default.
he always sets someone else project as the default.
i find that the project that he sets as default is in the first position by the solution file.
so i ended up by moving the position of my favorite project as the first one on that file (.sln). so my favorite project remains the default.
i would be happy to have a normal solution to that odded situation.

Related

Why is '.editorconfig' not doing anything in Visual Studio 2017?

I have the following version of Visual Studio:
Microsoft Visual Studio Community 2017 Version 15.1 (26403.7) Release
VisualStudio.15.Release/15.1.0+26403.7
I created a new project and added a .editorconfig file at my solution base folder.
Its content is the following:
root = true
[*.cs]
indent_style = space:warning
indent_size = 12:warning
# C# and Visual Basic code style settings:
[{*.cs,*.vb}]
dotnet_style_qualification_for_field = false:warning
The file location should be right:
.editorconfig <-- Here it is
ApplicationInsights.config
App_Data
App_Start
bin
Content
Controllers
favicon.ico
fonts
Global.asax
Global.asax.cs
Models
obj
packages.config
Properties
Scripts
Startup.cs
Views
Web.config
Web.config.backup.1
Web.Debug.config
Web.Release.config
WebApplication8.csproj
WebApplication8.csproj.user
But whenever I edit a .cs file, nothing special happen (despite indentation not following the rule), I expect a warning (after a build, for instance) to show up, but no.
Is there something wrong with my configuration, or is there something which could hinder the configuration from being applied?
I had this same problem. The solution was adding the .editorconfig file to the solution in my case. You can choose to either add it to the solution or the project, depending on whether you want it applied everywhere or just the individual project.
Solution Explorer → right-click your solution or project → Add → Existing Item... (if you have the .editorconfig file in position at the root of the solution or project) or New Item... (then search for editorconfig in the Add New Item wizard and choose the appropriate type for your work).
I solved a similar issue by placing the .editorconfig file at the root folder of the project, i.e., the same folder as your .sln file.
Try to put the .editorconfig file into the same folder as your source file. If it helps, try to move it up (into one of the parent directories) until you get it high enough to affect all the files you need.
If you have any EditorConfig extensions installed, try to uninstall them. There were some related bugs reported.
I had a similar problem and this is how I solved it:
My solution folder had a parent folder named between square brackets [], like [ParentFolderName], so I removed the square brackets and everything worked as expected.
For a reason or another, the editorconfig file does not do anything when the solution folder has a parent folder named between square brackets. The IDE (in my case Visual Studio 2017) uses its settings.

Open files in NetBeans 8.0.2 are kept in the project file thus making it dirty in GIT

I've been using NetBeans for the last couple of years and only recently upgraded to 8.0.2. It seems that the new project file tracks which files are open in the project workspace (C++) and thus the project file appears as modified whenever I open Netbeans, although I haven't changed anything. Is there a setting to disable this?
Create a file named ".gitignore" in the top-level directory, if it does not
already exist.
Add the line:
nbproject/private/
To do this with Netbeans:
Window -> Files, Select the Directory and right-click for Pop-up.
New -> Other ... -> Empty File.
Name the file ".gitignore"
When you do diffs and commits etc. it should ignore the private files that might have changed.

Renaming in IAR Embedded Work Bench

Is it possible to rename workspaces or projects? I am using 6.5_2 (although I have full versions of previous releases 4.0, 6.0)
To rename a workspace, but keep the projects in it all the same name as before, just simply rename the .eww file.
Since IAREWB doesn't actually provide the functionality to specifically rename a project, a work-around is required. What I do when trying to rename a workspace and it's associated project, I do this...
Copy Template.ewp (the project file) and rename the copy to say NewProject.ewp
Open Template.eww
Select Project->Add Existing Project...
Select NewProject.ewp and press Open
Select the "Template" tab at the bottom of the Workspace view
Right-click the project and select Remove
Close IAREWB, it will ask you to save the workspace, do that.
Rename the .eww, ewd to NewProject.eww, NewProject.ewd (and .dep if you have it)
Delete Template.ewp
You should then be able to open NewProject.eww as a completely renamed workspace and project.
If you want to only rename a project and keep the workspace the same name, only do steps 1-7
Hope that helps. and Good luck!
Pretty late to the party on this answer but I have had success renaming the .dep .ewd .ewp .ewt and .eww project files to the new project name and then using your text editor of choice to modify the .eww to point to the renamed .ewp (example below):
<?xml version="1.0" encoding="UTF-8"?>
<workspace>
<project>
<path>$WS_DIR$\my_new_project.ewp</path>
</project>
<batchBuild />
</workspace>
The advantage here being that if the project is under version control you won't have the add/remove of the .ewp which is advantageous, particularly working with multiple branches.
Once the file names are updated and the .eww is edited I have been able to open the project with no workspace, compilation or build errors (all assuming it compiled/built to start with).

Changing output directory in VS2010 project doesn't work

I have combined several projects into one solution. I created empty solution and added these projects and here is a blue print of how it looks like:
Root:
Project1 - directory
Project2 - directory
Debug - directory
Main.sln - file
Now I want to direct the executable and dll from both projects to \debug folder shown up of the solution file. I go into project properites >> Configuration Properities >> General >> 'Output Directory' and change the output directory to $(SolutionDir)$(Configuration)\ which is default for a new project.
The problem is that it has no effect on where the output file is created, it is still created in the old destination. The old path for `Output Directory' was .\Debug\ not that it matters.
Could this be because the SolutionDir & Configuration may not be defined? Where can I see their definition or values? I also want to create a new configuration which would be 'Release with Debug' how can I create that using environment variable? Thanks!
My project is MFC/Visual C++.
Add-on:
Where are these identifiers like SolutionDir defined in the scrip? I look up for in .vcxproj file but there is mention of it. I create a new dummy VS2010 project just to look at it's .vcxproj file but these project settings identified are not defined in any place that I can see!
This is most likely caused by specific settings overriding global settings, namely Linker's "output" setting. This happens often as a result of conversion from earlier Visual Studio.
What you need is to go through every setting, paying attention to those whose values are written in bold, and reset to default (select it from dropdown) every setting with 'debug' or 'release', and others as necessary.
There could also be specific settings on files. I usually resolve this by opening project in notepad and removing any excessive settings. Just be careful. Using multiline replace in Notepad++ or any other capable editor helps.
I think I had a similar problem.
What I ended up doing was editing the vcxproj file directly. Find this section and edit it like this for each of your configurations:
<PropertyGroup>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
</PropertyGroup>
I had a similar problem with the Intermediate Directory setting in one of my VS2010 projects. No matter what I set it to, it would always use the default value of $(SolutionDir)$Configuration. Oddly, other projects in the same solution with the same settings worked just fine.
After playing around, I stumbled upon a solution.
Click on the setting in the propery page dialog.
Click on the down arrow button in the right-hand side of the edit box.
Select "inherit from parent or project defaults".
Click "Apply".
Click on the setting and change it to your desired value.
I don't know why this works, but it does. It seems like the macros were not being properly evaluated for whatever reason. Then, after you apply the inherited values, it seems to reset itself and start evaluating the macros properly.

VS2008 win32 project defaults - remove default precompiled headers

I have been through every option to try to find a way to get the IDE to let me create a new win32pject without precompiled headers. I have read every thread on this forum with the words "precpmpiled headers" in it and the closest I got was:
Precompiled Headers
Using 2008 pro (not express, althought the behaviour seems to be similar) I go to:
File -> New -> Project
This opens the New Project dialog in which I select Visual C++ Win32 Project, enter a name and hit OK.
THen I get the "Win32 Application Wizard". With the Application Type set to "Windows Application", the application settings pane will not allow me to uncheck the pre-compiled headers. THe check box is greyed out. IF I choose "Console Application" I can uncheck it, but I am creating a GUI app.
WHen I click Finish I get 6 yards of code in xxx.cpp, four header files and the obligatory stdafx.cpp.
Perhaps I could remove and delete all this stuff and the go into the properties and turn off PCH, but thats a hasssel for the many small project examples I want to write.
I just want an empty project that will compile to a win32 app, so how do i change the PCH default to NONE?
You could make your own template to do this, or you could edit the default one. The relevant wizard can be found here:
C:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\AppWiz\Generic\Application
Obviously if you're gonna edit the default template, backup the folder first.
I'll show you how to get started on editing it.
First of all you need to tell the wizard script that you don't want precompiled headers. Edit this file in your favourite text editor:
\scripts\1033\default.js
Find this line:
var Pch = wizard.FindSymbol("PRE_COMPILED_HEADER");
and comment out some of the lines below it like this:
// if ((strAppType == "LIB" || ((strAppType == "CONSOLE") &&
// !wizard.FindSymbol("SUPPORT_MFC") && !wizard.FindSymbol("SUPPORT_ATL"))) && !Pch)
{
AddFilesToProjectWithInfFile(selProj, strProjectName);
SetNoPchSettings(selProj);
}
// else
// {
// AddFilesToProjectWithInfFile(selProj, strProjectName);
// SetCommonPchSettings(selProj);
// }
Now open this file:
\templates\1033\Templates.inf
and find the first occurrence of [!else] and delete these 3 lines below it:
stdafx.h
targetver.h
stdafx.cpp
This will give you a project without stdafx.cpp/.h or targetver.h, and the CPP file will not try to use a PCH. However it won't build because we haven't added any #includes to the appropriate header files. I'll leave that for you to figure out :)
(you can edit the files that get generated automatically by modifying the files in \templates\1033)
either choose an empty project, or create your own wizard in which you use a template. Since you say you don't want to change properties the whole time, I'd also strongly suggest using property sheets (vsprops). This way, you create an empty project, add the property sheets you want, and you'r ready to go. No more fiddling with properties, and each project uses the same set.
Mark the "Empty Project" check box in the "additional options", in the Application Settings dialog.
The "Empty Project" option will create a project without precompiled headers. At least, this is what I get on Visual Studio 2008 SP1.
It's true that the "Use precompiled headers" remain checked, but the project will have the property UsePrecompiledHeader="0" and the wizard won't create the files.
I'm jumping way late on this bandwagon, as I'm having the same issues for VS2010.
I'm not sure if this solution would apply for VS2008.
Since there are no settings or options under tools which would enable me to default to an empty project, I searched around and found the following:
in the folder
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\VCWizards\AppWiz\Generic\Application\html\1033
there is a file named default.htm
in the </HEAD> section, there are two lines:
<SYMBOL NAME="EMPTY_PROJECT" TYPE=checkbox VALUE=false></SYMBOL>
<SYMBOL NAME="PRE_COMPILED_HEADER" TYPE=checkbox VALUE=true></SYMBOL>
which I replaced with
<SYMBOL NAME="EMPTY_PROJECT" TYPE=checkbox VALUE=true></SYMBOL>
<SYMBOL NAME="PRE_COMPILED_HEADER" TYPE=checkbox VALUE=false></SYMBOL>
(in other words, I just switched true and false on those lines)
and now I have an empty project by default when I create a console app.
I don't know the repercussions as to what it will affect when I do something other than console apps, but since I saved the original file, I can just revert to the old M$ settings.
You can just select 'empty project' under 'additional options'. Then you get a project with no precompiled headers, and no autogenerated files.
I don't know what it is with Microsoft's obsession with forcing precompiled headers even in the smallest test project. Presumably it's based in the same philosphy that gave us the macro hell that is windows.h, or the way even an empty project overrides two dozen project settings, making property sheets almost useless.
I suspect there's simply a strong mafia inside Microsoft's developer division, who's doing everything they can to prevent Visual Studio from becoming a useful tool for C++ developers. So far, they're doing a very good job of it.