Open livarcocc opened 6 years ago
From @davkean on July 4, 2017 8:16
There's project.assets.json file in the obj directory that I believe is triggering this. Was this project ever a .NET Core project at one point in history? Or did it contain a <TargetFramework>
property ever at one point?
From @aliostad on July 4, 2017 8:19
Thanks for fast response! Well, I have been playing around trying to figure out best approach, or it could have been left from the other branch which will be .NET Standard. Most possibly the latter, I wouldn't normally mess around with master
.
From @davkean on July 4, 2017 8:22
Yeah that's the problem, we need to think we would handle this case. I suspect we'd run into the same issue when switching between branches for a legacy project that had opt'd into <PackageReference/>
and one that hadn't.
From @aliostad on July 4, 2017 8:23
Good to hear. At least now I know how to resolve, I hope you fix it since it can be very annoying. Thanks for your help 👍
From @aliostad on July 4, 2017 14:2
Also, the question is why "Clean Solution", did not remove these. I at least cleaned the solution like 10 times. I would expect obj folder to go.
From @chlowell on August 9, 2017 21:57
I have a repro of what looks like the same issue here. A newly-created Framework 4.5 project gives the same NuGet restore error on load, and fails to build, when it's adjacent to a netstandard2.0 project.
I can only repro this in VS, as such, I will move this issue to be further investigated in the dotnet/project-system repo.
@livarcocc I think the request for clean to remove the file would be an SDK issue (though against the general policy that clean doesn't remove things it doesn't know about).
Also, what part can you only repro in VS? The NuGet build task should behave the same for command line builds.
I am talking about @chlowell repro above. I can build his project in the command line, however, in VS I get an error Your project is not referencing the ".NETFramework,Version=v4.5...
Got it - thanks.
Please advise the status on this bug ??? It is driving me mad
We're discussing ways that we might be able to address it, but for now, the recommendation is to delete your obj
directory (maybe via git clean -xdf
) when you switch between branches like this, and in general not to structure things so that you have the two different projects in the same folder.
We currently have a previous version of an app being supported and work on a new one where devs often switch between branches and going and deleting 30-40 obj folders doesn't make them happy campers, especially since a lot are Java devs who aren't as experienced in VS/Nuget/msbuild. I created a basic target to remove the problematic nuget files on clean.
<CleanDependsOn>
$(CleanDependsOn);
CleanNuget;
</CleanDependsOn>
It seemed to work great until rebuild failed related to the issue referenced above "Visual Studio fails to restore PackageReferences when bin and obj folders have been deleted #4528". I added a property to flag nuget builds but the depend setup didn't seem to honor it so the fix I found was using AfterTargets="Clean".
<Target Name="CleanNuget" AfterTargets="Clean" Condition="'$(NugetBuild)'==''">
<ItemGroup>
<NugetFiles Include="$(BaseIntermediateOutputPath)*.nuget.*" />
<NugetFiles Include="$(BaseIntermediateOutputPath)*.assets.json" />
</ItemGroup>
<Message Text="$(MSBuildProjectName): Cleaning Nuget intermediate files..." Importance="high" />
<Delete Files="@(NugetFiles)" />
</Target>
I was wondering if there was already a property marking projects that use nuget packages so we weren't maintaining extraneous ones or if anyone had a critique of this approach.
If not maybe this workaround will help someone else.
This is still an issue, has there been any progress made on this? Having to manually remove the obj folders when moving between branches is less than ideal.
Just hit this after creating a new branch. https://developercommunity.visualstudio.com/content/problem/312180/projects-fail-to-build-in-1580-due-to-errors-from.html (which I found from searching: "your project file doesn't list 'win' as a runtimeidentifier") redirected me here. Clearing out src/obj folders via https://stackoverflow.com/questions/755382/i-want-to-delete-all-bin-and-obj-folders-to-force-all-projects-to-rebuild-everyt worked around the issue.
Two years later and this is still a problem... 🤦
this is still an issue in visual studio 2019. Switching branches causes this, if a project is an SDK style project in one branch, and an old-style project in another
Will this be fixed? We just changed some Projects from packages.config to PackageReference. Now every time I switch to an older branch, which is still running on packages.config, I have to clean the obj Folders. That is very annoying and time consuming.
Just chiming in: VS 2022, just hit this error and the nuking the obj
folder of the listed project/s* seems to still be the resolution.
*I'm working with a large-ish solution so the fact that the affected project/s is/are listed is very helpful...otherwise....
When is this going to be fixed? My team is using VS 2022 and we have solutions with 50+ projects and deleting the entire bin/obj folder is less than ideal.
From @aliostad on July 4, 2017 8:13
So this is the context of the conversation, where @davkean advised me to create this issue.
I had started porting PerfIt to .NET Standard in a different branch and it seems something makes VS 2017 to think it is .NET Core.
I have changed
ToolsVersion
to 12.0, 14.0 and 15.0 to no avail. I cloned the project in a clean location and VS 2017 had no issue so it seems something in my working folder that does this. I also rangit clean -d -f
and no difference.So I think in order to reproduce, I have to share with you my environment which is zipped in the file below. As for me, I will clean up and start again but I hope you get to the bottom of this since it was utterly annoying and wasted 6-7 hours (I started reducing project to one project and compare with other projects that work). Thanks in advance.
Anyway here is the file https://drive.google.com/file/d/0By4PF7Jis9FzNHVMR21KTjJZY3M/view?usp=sharing
Full build output
``` 1>Project 'PerfIt' is not up to date. Missing output file 'C:\Users\aliostad\Documents\GitHub\PerfIt\src\PerfIt\bin\Debug\PerfIt.dll'. 1>------ Build started: Project: PerfIt, Configuration: Debug Any CPU ------ 1>Build started 03/07/2017 10:39:31. 1>Environment at start of build: 1>ALLUSERSPROFILE = C:\ProgramData 1>APPDATA = C:\Users\aliostad\AppData\Roaming 1>ChocolateyInstall = C:\ProgramData\chocolatey 1>ChocolateyLastPathUpdate = Thu Jun 29 22:09:54 2017 1>ChocolateyToolsLocation = C:\tools 1>CommonProgramFiles = C:\Program Files (x86)\Common Files 1>CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files 1>CommonProgramW6432 = C:\Program Files\Common Files 1>COMPUTERNAME = DESKTOP-T1V7TC3 1>ComSpec = C:\Windows\system32\cmd.exe 1>HOMEDRIVE = C: 1>HOMEPATH = \Users\aliostad 1>LOCALAPPDATA = C:\Users\aliostad\AppData\Local 1>LOGONSERVER = \\DESKTOP-T1V7TC3 1>MSBuildLoadMicrosoftTargetsReadOnly = true 1>NUMBER_OF_PROCESSORS = 2 1>OneDrive = C:\Users\aliostad\OneDrive 1>OS = Windows_NT 1>Path = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Users\aliostad\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\GitExtensions\;C:\Users\aliostad\AppData\Local\GitHub\PortableGit_f02737a78695063deace08e96d5042710d3e32db\cmd;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Users\aliostad\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Microsoft VS Code\bin;C:\tools\cmder; 1>PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC 1>PkgDefApplicationConfigFile = C:\Users\aliostad\AppData\Local\Microsoft\VisualStudio\15.0_aa78f840\devenv.exe.config 1>PROCESSOR_ARCHITECTURE = x86 1>PROCESSOR_ARCHITEW6432 = AMD64 1>PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 69 Stepping 1, GenuineIntel 1>PROCESSOR_LEVEL = 6 1>PROCESSOR_REVISION = 4501 1>ProgramData = C:\ProgramData 1>ProgramFiles = C:\Program Files (x86) 1>ProgramFiles(x86) = C:\Program Files (x86) 1>ProgramW6432 = C:\Program Files 1>PSModulePath = C:\Users\aliostad\Documents\WindowsPowerShell\Modules 1>PUBLIC = C:\Users\Public 1>SESSIONNAME = Console 1>SystemDrive = C: 1>SystemRoot = C:\Windows 1>TEMP = C:\Users\aliostad\AppData\Local\Temp 1>TMP = C:\Users\aliostad\AppData\Local\Temp 1>USERDOMAIN = DESKTOP-T1V7TC3 1>USERDOMAIN_ROAMINGPROFILE = DESKTOP-T1V7TC3 1>USERNAME = aliostad 1>USERPROFILE = C:\Users\aliostad 1>VisualStudioDir = C:\Users\aliostad\Documents\Visual Studio 2017 1>VisualStudioEdition = Microsoft Visual Studio Enterprise 2017 1>VisualStudioVersion = 15.0 1>VS140COMNTOOLS = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\ 1>VSAPPIDDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ 1>VSAPPIDNAME = devenv.exe 1>VSLANG = 1033 1>windir = C:\Windows 1> 1>Initial Properties: 1>_AfterCompileWinFXInternalDependsOn = 1> PrepareResourcesForSatelliteAssemblies; 1> MergeLocalizationDirectives; 1> AfterCompileWinFX 1> 1>_CompileTargetNameForLocalType = _CompileTemporaryAssembly 1>_DebugSymbolsProduced = true 1>_DeploymentApplicationManifestIdentity = Native.PerfIt 1>_DeploymentBuiltUpdateInterval = 0 1>_DeploymentBuiltUpdateIntervalUnits = Days 1>_DeploymentDeployManifestIdentity = PerfIt.application 1>_DeploymentFileMappingExtension = 1>_DeploymentTargetApplicationManifestFileName = Native.PerfIt.manifest 1>_DeploymentUrl = 1>_DirectoryBuildPropsBasePath = 1>_DirectoryBuildPropsFile = Directory.Build.props 1>_DirectoryBuildTargetsBasePath = 1>_DirectoryBuildTargetsFile = Directory.Build.targets 1>_DocumentationFileProduced = true 1>_GenerateBindingRedirectsIntermediateAppConfig = obj\Debug\PerfIt.csproj.PerfIt.dll.config 1>_GenerateRestoreGraphProjectEntryInputProperties = 1> RestoreUseCustomAfterTargets=; 1> NuGetRestoreTargets=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets; 1> BuildProjectReferences=false; 1> ExcludeRestorePackageImports=true; 1> 1>_GetChildProjectCopyToOutputDirectoryItems = true 1>_NuGetRuntimeIdentifierWithoutAot = win 1>_OriginalConfiguration = Debug 1>_OriginalPlatform = AnyCPU 1>_ProjectDefaultTargets = Build 1>_RequireMCPass2ForMainAssembly = false 1>_RequireMCPass2ForSatelliteAssemblyOnly = false 1>_ResolveReferenceDependencies = false 1>_ResourceNameInMainAssembly = PerfIt.g.resources 1>_SGenDllCreated = false 1>_SGenDllName = PerfIt.XmlSerializers.dll 1>_SGenGenerateSerializationAssembliesConfig = Off 1>AddAdditionalExplicitAssemblyReferences = true 1>AddItemTemplatesGuid = {FAE04EC0-301F-11d3-BF4B-00C04F79EFBC} 1>AdditionalExplicitAssemblyReferences = System.Core; 1>AllowedReferenceAssemblyFileExtensions = 1> .winmd; 1> .dll; 1> .exe 1> 1>AllowedReferenceRelatedFileExtensions = 1> .pdb; 1> .xml; 1> .pri; 1> .dll.config; 1> .exe.config 1> 1>ALLUSERSPROFILE = C:\ProgramData 1>AlwaysCompileMarkupFilesInSeparateDomain = true 1>AlwaysUseNumericalSuffixInItemNames = true 1>AndroidTargetsPath = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\MDD\Android\V150\ 1>APPDATA = C:\Users\aliostad\AppData\Roaming 1>AppDesignerFolder = Properties 1>AppDesignerFolderContentsVisibleOnlyInShowAllFiles = false 1>AssemblyFoldersConfigFile = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\AssemblyFolders.config 1>AssemblyFoldersConfigFileSearchPath = {AssemblyFoldersFromConfig:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\AssemblyFolders.config,v4.5}; 1>AssemblyFoldersSuffix = AssemblyFoldersEx 1>AssemblyName = PerfIt 1>AssemblySearchPaths = 1> {CandidateAssemblyFiles}; 1> ; 1> {HintPathFromItem}; 1> {TargetFrameworkDirectory}; 1> {AssemblyFoldersFromConfig:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\AssemblyFolders.config,v4.5}; 1> {Registry:Software\Microsoft\.NETFramework,v4.5,AssemblyFoldersEx}; 1> {AssemblyFolders}; 1> {GAC}; 1> {RawFileName}; 1> bin\Debug\ 1> 1>AssignTargetPathsDependsOn = 1>AutoUnifyAssemblyReferences = true 1>AvailablePlatforms = Any CPU,x86,x64 1>BaseIntermediateOutputPath = obj\ 1>BaseNuGetRuntimeIdentifier = win 1>BuildCompileAction = Build 1>BuildDependsOn = 1> EntityDeploy; 1> 1> BeforeBuild; 1> CoreBuild; 1> AfterBuild 1> 1> 1>BuildGenerateSourcesAction = Build 1>BuildingInsideVisualStudio = true 1>BuildingOutOfProcess = true 1>BuildingProject = false 1>BuildInParallel = true 1>BuildLinkAction = Build 1>BuildProjectReferences = true 1>BuildSystem = MSBuild 1>BuildTaskAssembly = PresentationBuildTasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 1>BuiltProjectOutputGroupDependsOn = PrepareForBuild 1>ChocolateyInstall = C:\ProgramData\chocolatey 1>ChocolateyLastPathUpdate = Thu Jun 29 22:09:54 2017 1>ChocolateyToolsLocation = C:\tools 1>CleanDependsOn = 1> 1> BeforeClean; 1> UnmanagedUnregistration; 1> CoreClean; 1> CleanReferencedProjects; 1> CleanPublishFolder; 1> AfterClean 1> ; 1> EntityClean; 1> 1>CleanFile = PerfIt.csproj.FileListAbsolute.txt 1>CodeAnalysisApplyLogFileXsl = false 1>CodeAnalysisFailOnMissingRules = false 1>CodeAnalysisForceOutput = true 1>CodeAnalysisGenerateSuccessFile = true 1>CodeAnalysisIgnoreGeneratedCode = true 1>CodeAnalysisIgnoreInvalidTargets = true 1>CodeAnalysisIgnoreMissingIndirectReferences = false 1>CodeAnalysisInputAssembly = bin\Debug\PerfIt.dll 1>CodeAnalysisLogFile = bin\Debug\PerfIt.dll.CodeAnalysisLog.xml 1>CodeAnalysisModuleSuppressionsFile = GlobalSuppressions.cs 1>CodeAnalysisOutputToConsole = false 1>CodeAnalysisOverrideRuleVisibilities = false 1>CodeAnalysisPath = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Static Analysis Tools\FxCop\ 1>CodeAnalysisQuiet = false 1>CodeAnalysisRuleDirectories = ;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Static Analysis Tools\FxCop\\Rules 1>CodeAnalysisRuleSet = MinimumRecommendedRules.ruleset 1>CodeAnalysisRuleSetDirectories = ;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Static Analysis Tools\\Rule Sets 1>CodeAnalysisSaveMessagesToReport = Active 1>CodeAnalysisSearchGlobalAssemblyCache = true 1>CodeAnalysisStaticAnalysisDirectory = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Static Analysis Tools\ 1>CodeAnalysisSucceededFile = bin\Debug\PerfIt.dll.lastcodeanalysissucceeded 1>CodeAnalysisSummary = false 1>CodeAnalysisTargets = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\CodeAnalysis\Microsoft.CodeAnalysis.targets 1>CodeAnalysisTimeout = 120 1>CodeAnalysisTreatWarningsAsErrors = false 1>CodeAnalysisUpdateProject = false 1>CodeAnalysisUseTypeNameInSuppression = true 1>CodeAnalysisVerbose = false 1>CommonProgramFiles = C:\Program Files (x86)\Common Files 1>CommonProgramW6432 = C:\Program Files\Common Files 1>CommonTargetsPath = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 1>CommonXamlResourcesDirectory = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\\ 1>CompileDependsOn = 1> 1> ResolveReferences; 1> ResolveKeySource; 1> SetWin32ManifestProperties; 1> _GenerateCompileInputs; 1> BeforeCompile; 1> _TimeStampBeforeCompile; 1> _GenerateCompileDependencyCache; 1> CoreCompile; 1> _TimeStampAfterCompile; 1> AfterCompile; 1> ; 1> _AfterCompileWinFXInternal 1> 1>CompileLicxFilesDependsOn = 1>CompileTargetNameForTemporaryAssembly = CompileTemporaryAssembly 1>ComputeIntermediateSatelliteAssembliesDependsOn = 1> CreateManifestResourceNames 1> 1>COMPUTERNAME = DESKTOP-T1V7TC3 1>ComReferenceExecuteAsTool = false 1>ComReferenceNoClassMembers = false 1>ComSpec = C:\Windows\system32\cmd.exe 1>Configuration = Debug 1>ConfigurationName = Debug 1>ConsiderPlatformAsProcessorArchitecture = true 1>ContentFilesProjectOutputGroupDependsOn = PrepareForBuild;AssignTargetPaths 1>ContinueOnError = false 1>CopyNuGetImplementations = true 1>CoreBuildDependsOn = 1> BuildOnlySettings; 1> PrepareForBuild; 1> PreBuildEvent; 1> ResolveReferences; 1> PrepareResources; 1> ResolveKeySource; 1> Compile; 1> ExportWindowsMDFile; 1> UnmanagedUnregistration; 1> GenerateSerializationAssemblies; 1> CreateSatelliteAssemblies; 1> GenerateManifests; 1> GetTargetPath; 1> PrepareForRun; 1> UnmanagedRegistration; 1> IncrementalClean; 1> PostBuildEvent 1> 1>CoreCleanDependsOn = 1>CoreCompileDependsOn = 1> GenerateCompiledExpressionsTempFile; 1> 1> DesignTimeXamlMarkupCompilation; 1> 1> DesignTimeMarkupCompilation; 1> _ComputeNonExistentFileProperty;ResolveCodeAnalysisRuleSet 1> 1> 1> 1>CoreResGenDependsOn = 1>CreateCustomManifestResourceNamesDependsOn = 1>CreateHardLinksForCopyAdditionalFilesIfPossible = false 1>CreateManifestResourceNamesDependsOn = 1>CreateSatelliteAssembliesDependsOn = 1> _GenerateSatelliteAssemblyInputs; 1> ComputeIntermediateSatelliteAssemblies; 1> GenerateSatelliteAssemblies 1> 1>CreateSymbolicLinksForCopyAdditionalFilesIfPossible = false 1>CSharpCoreTargetsPath = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets 1>CSharpDesignTimeTargetsPath = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\Managed\Microsoft.CSharp.DesignTime.targets 1>CSharpTargetsPath = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.CSharp.CurrentVersion.targets 1>CurrentSolutionConfigurationContents =Copied from original issue: dotnet/sdk#1382