dotnet / upgrade-assistant

A tool to assist developers in upgrading .NET Framework applications to .NET 6 and beyond
MIT License
1.1k stars 163 forks source link

--vs-path not working when vs 2017 and 2022 installed #1405

Open dcworldwide opened 1 year ago

dcworldwide commented 1 year ago

Describe the bug

I have vs 2017 and 2022 installed. I have tried the following command from a VS 2017 and VS 2022 developer prompt. As well as from a standard powershell prompt. I am using --vs-path to specify the path to VS 2022 install All produce the same issue. VS 2017 is selected by the tool. The tool fails. It should be respecting my vs path flag and choosing 2022. Error below

upgrade-assistant upgrade C:\projects\srms-next\Common\Development\EsriCore\EsriCore.csproj --vs-path "C:\Program Files\Microsoft Visual Studio\2022\Professional"

Microsoft .NET Upgrade Assistant v0.4.355802+b2aeae2c0e41fbfed35df6ab2e88b82a0c11be2b

[15:52:16 INF] Loaded 9 extensions [15:52:19 INF] Using MSBuild from C:\Program Files\dotnet\sdk\6.0.102\ [15:52:19 INF] Using Visual Studio install from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional [v15] [15:52:24 INF] Loading upgrade progress file at C:\projects\srms-next\Common\Development\EsriCore.upgrade-assistant [15:52:24 INF] Initializing upgrade step Back up project [15:52:24 INF] Initializing upgrade step Convert project file to SDK style

Error

[15:59:39 INF] Applying upgrade step Convert project file to SDK style [15:59:39 INF] Converting project file format with try-convert, version 0.4.355802+b2aeae2c0e41fbfed35df6ab2e88b82a0c11be2b [15:59:39 ERR] Unexpected error applying step Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Current\Microsoft.Common.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Current\Microsoft.Common.props" is correct, and that the file exists on disk. C:\Program Files\dotnet\sdk\6.0.102\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Current\Microsoft.Common.props does not exist. But C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Microsoft.Common.props does. Which is why i'm trying to set --vs-path.

.csproj file


<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{0E43B108-C5D6-49A4-BF50-282ACDF18355}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>EsriCore</RootNamespace>
    <AssemblyName>EsriCore</AssemblyName>
    <SignAssembly>true</SignAssembly>
    <AssemblyOriginatorKeyFile>EsriCoreKey.snk</AssemblyOriginatorKeyFile>
    <SccProjectName>
    </SccProjectName>
    <SccLocalPath>
    </SccLocalPath>
    <SccAuxPath>
    </SccAuxPath>
    <SccProvider>
    </SccProvider>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <OldToolsVersion>2.0</OldToolsVersion>
    <UpgradeBackupLocation />
    <TargetFrameworkProfile />
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
    <RestorePackages>true</RestorePackages>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <LangVersion>6</LangVersion>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <LangVersion>6</LangVersion>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="ESRI.ArcGIS.System, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86">
      <SpecificVersion>False</SpecificVersion>
      <Private>False</Private>
    </Reference>
    <Reference Include="ESRI.ArcGIS.Version, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86">
      <SpecificVersion>False</SpecificVersion>
      <Private>False</Private>
    </Reference>
    <Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
      <HintPath>..\..\..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Compression\CompressionService.cs" />
    <Compile Include="Compression\FileFilter.cs" />
    <Compile Include="Diagnostics\ArcGisComExceptionMap.cs" />
    <Compile Include="DisposableHelper.cs" />
    <Compile Include="License\ArcGisLicenseManagerException.cs" />
    <Compile Include="Exceptions\EsriBaseException.cs" />
    <Compile Include="Guid\ArcGuid.cs" />
    <Compile Include="License\ArcGis10LicenseManager.cs" />
    <Compile Include="License\ArcGis10LicenseManager.Designer.cs">
      <DependentUpon>ArcGis10LicenseManager.cs</DependentUpon>
    </Compile>
    <Compile Include="Logging\IEsriLog.cs" />
    <Compile Include="Logging\Log.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Testing\DataDrivenTest.cs" />
    <Compile Include="Testing\RequiredColumnNotFoundException.cs" />
    <Compile Include="Testing\TestCaseRow.cs" />
    <Compile Include="Utils.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="EsriCoreKey.snk" />
    <None Include="packages.config" />
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
ltsar-federated commented 1 year ago

+1 Have the same bug. upgrade-assistant is ignoring the --vs-path flag.