Change assembly name based on configuration (Visual Studio 2005/2008) - visual-studio

Is it possible to change the assembly name based on the project configuration?
I have tried conditional pragmas on the assemblyinfo.cs file, but that only changes the assembly attributes, not the name itself.

If you right click on your project and choose "Edit Project File" (I'm in 2008 here and it may be a new option, if it is then just open the project file in any old text editor) you should see something similar to the following:
<PropertyGroup>
...
<AssemblyName>ClassLibrary1</AssemblyName>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
</PropertyGroup>
Basically any properties that aren't overriden in a more specific property group are inherited from the more general, first group. So to achieve what you want just edit the file so that the AssemblyName tag is defined in each of the specific groups:
<PropertyGroup>
...
<AssemblyName>ClassLibrary1</AssemblyName>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<AssemblyName>ClassLibrary1Debug</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
<AssemblyName>ClassLibrary1Release</AssemblyName>
</PropertyGroup>
This will change the assembly name on a per config basis.

Related

Visual Studio Mac showing Hammer icon no run button - Xamarin.Forms

I have VS Mac 2022 with xamarin.forms project and android project is set as startup.
When I want to run the app there is no Run button only Hammer icon showing up in VS at top left corner. I am not sure what's going wrong here.
This is android project android configuration file.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>s_Order.Droid</RootNamespace>
<AndroidApplication>True</AndroidApplication>
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<DebugType>portable</DebugType>
<PlatformTarget>x86</PlatformTarget>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<IntermediateOutputPath></IntermediateOutputPath>
<ConsolePause>true</ConsolePause>
<ExternalConsole>false</ExternalConsole>
<Commandlineparameters></Commandlineparameters>
<RunWithWarnings>true</RunWithWarnings>
<AndroidManagedSymbols>false</AndroidManagedSymbols>
<MandroidExtraArgs></MandroidExtraArgs>
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
<BundleAssemblies></BundleAssemblies>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<EnableLLVM>false</EnableLLVM>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Release</OutputPath>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<ExternalConsole>false</ExternalConsole>
<AotAssemblies></AotAssemblies>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<EnableLLVM>false</EnableLLVM>
<EmbedAssembliesIntoApk></EmbedAssembliesIntoApk>
</PropertyGroup>
</Project>
Please check below screenshot
Below is compiler options for android
How can I fix this ?
Adding the project type guids and the android manifest to the first property group seems to fix the problem. The main toolbar in Visual Studio for Mac shows the run arrow icon instead of the hammer icon when this is done:
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
The missing AndroidManifest seems to be the main culprit. Although I had to add the project type guids too - otherwise it seemed to prevent Visual Studio for Mac from allowing the Android project to be set as a startup project.

Problems building with ImageResizer FastScaling in release mode

I am having problems getting my project to build in Release mode (both locally and externally) after adding FastScaling 64 bit version. I noticed the problem when trying to build the solution with TeamCity. Whilst in debug mode locally it works fine.
The error I am getting is "Could not load file or assembly 'ImageResizer.Plugins.FastScaling' or one of its dependencies. An attempt was made to load a program with an incorrect format.".
I am trying to build the solution with VS2015 and the VC++ 2015 redistributable 64bit installed. I have also set the platform target for the project to x64, and checked the "Use the 64 bit version of IIS Express for web sites and projects."-box.
The setup looks like this in the proj file:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion></ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>guid</ProjectGuid>
<ProjectTypeGuids>guid</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ProjectName.Web</RootNamespace>
<AssemblyName>ProjectName.Web</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<MvcBuildViews>true</MvcBuildViews>
<UseIISExpress>true</UseIISExpress>
<FileUpgradeFlags></FileUpgradeFlags>
<UpgradeBackupLocation></UpgradeBackupLocation>
<OldToolsVersion>12.0</OldToolsVersion>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
<IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
<IISExpressUseClassicPipelineMode>false</IISExpressUseClassicPipelineMode>
<TargetFrameworkProfile />
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp></NuGetPackageImportStamp>
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
Any pointers to what I can try?
Somehow you're getting 32-bit FastScaling jnstead ofn64-bit or vice versa. Inspect the /bin directory to see which one is actually being copied over.

Build Visual Studio project with different compilation symbols

I have a VS solution file that contains 1 project. I've been trying to write the project file such that there's a single build target that will build the same project multiple times with different compilation symbols each.
This project is a library that is intended to be used in a mobile Unity project. The library uses #if directives for each platform: Android, iOS and Desktop.
My goal is to build the same project in a different folder with different compilation symbols:
Debug
Android
Lib.DLL ("UNITY_ANDROID" compilation symbols)
iOS
Lib.DLL ("UNITY_IPHONE" compilation symbols)
Standalone
Lib.DLL ("" compilation symbols)
Release
Android
Lib.DLL ("UNITY_ANDROID" compilation symbols)
iOS
Lib.DLL ("UNITY_IPHONE" compilation symbols)
Standalone
Lib.DLL ("" compilation symbols)
Originally, I would manually edit the project file, set the compilation symbols, build, rinse and repeat. It kinda worked, but it was messy.
I then discovered that there's a way to do this in a single project file, but I have yet to figure out how. I've tried this with no success.
To give a little more context, I'm using CakeBuild to build the project and this is how I'm calling the project target:
DotNetBuild("./Lib/Lib.sln", settings => settings.WithTarget("Build"));
I am totally OK with calling that line multiple times with different configurations or targets, but I have not found a way to change the compilation symbols.
Here's a snippet of the project file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CF15E877-F285-496B-B748-C9A666D97D0F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>JsonDotNet</RootNamespace>
<AssemblyName>JsonDotNet</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug-Android' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\Android\lib\net35\</OutputPath>
<DefineConstants>UNITY_ANDROID</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug-iOS' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\iOS\lib\net35\</OutputPath>
<DefineConstants>UNITY_IPHONE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug-x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\iOS\lib\net35\</OutputPath>
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release-Android' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\Android\lib\net35\</OutputPath>
<DefineConstants>UNITY_ANDROID</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release-iOS' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\iOS\lib\net35\</OutputPath>
<DefineConstants>UNITY_IPHONE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release-x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\iOS\lib\net35\</OutputPath>
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<ProjectToBuild Include="..\Lib.sln">
<Properties>Configuration=Debug-iOS</Properties>
</ProjectToBuild>
<ProjectToBuild Include="..\Lib.sln">
<Properties>Configuration=Debug-Android</Properties>
</ProjectToBuild>
<ProjectToBuild Include="..\Lib.sln">
<Properties>Configuration=Debug-x86</Properties>
</ProjectToBuild>
<ProjectToBuild Include="..\Lib.sln">
<Properties>Configuration=Release-iOS</Properties>
</ProjectToBuild>
<ProjectToBuild Include="..\Lib.sln">
<Properties>Configuration=Release-Android</Properties>
</ProjectToBuild>
<ProjectToBuild Include="..\Lib.sln">
<Properties>Configuration=Release-x86</Properties>
</ProjectToBuild>
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="#(ProjectToBuild)" BuildInParallel="true" />
</Target>
When I run this, only Debug Android is built. I've also tried including the platform in the condition (i.e. Condition=" '$(Configuration)|$(Platform)' == 'Debug|iOS' ") with the same results.

Quick way to determine which projects in a VS solution target a specific version?

I have a visual studio solution with a large number of projects in it, some of which target .NET v2.0, and some of which target v3.5.
I know I can right click on each project in turn to see which version it targets, but this would take for ever.
Does anyone know a quicker way I can determine which projects target v2.0 and which target v3.5?
EDIT:
I was hoping to be able to use the TargetFrameworkVersion node to determine the version, but some of the project files don't have this node, e.g.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E11A268C-9F62-4970-9338-129C35AD2354}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BusinessEntities</RootNamespace>
<AssemblyName>Business Entities</AssemblyName>
</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>
</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>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="SomeClass.cs" />
<Compile Include="SomeOtherClass.cs" />
</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>
...but if I right click on the project in VS, it says that the target version is .NET v2.0. Also just to be clear, I need to repeat this process for a number of solutions, so doing it the manual way is a really undesirable option.
Thanks
There is a link might be helpful.
You have to write your own code to parse project files to get the framework versions.
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
The other option is to use command line for the solution folder.
Use MS DOS command:
findstr "<TargetFrameworkVersion>" *.csproj
The result will be displayed on the screen.
UPDATE:
Because older progjects don't contain this line. We can use another command, which search files don't contain the line.
findstr /v "<TargetFrameworkVersion>" *.csproj

Accessing the runtime library property in visual studio 2010

This is basically a follow up question to:
Using Visual Studio project properties effectively for multiple projects and configurations
Our library's target name is currently in this format:
$(ProjectName)-$(PlatformToolset)-$(PlatformShortName)-$(Configuration)
We'd like to add information about the runtime library used by the project to the target name, I tried adding $(RuntimeLibrary), but that doesn't seem to be set. Is there any other way to get the runtime library at the time the target name is resolved?
Thanks,
John.
With this property sheet you can do this. Import it in your property sheet and you will be able to access the RuntimeLibrary this way: $(RuntimeLibrary)
Yes!!! This will work in your propertie sheet =^.~=
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_IsDebug>$([System.Convert]::ToString($([System.Text.RegularExpressions.Regex]::IsMatch($(Configuration),'[Dd]ebug'))))</_IsDebug>
<_ItemDefinitionGroupRegex><![CDATA[<ItemDefinitionGroup Condition=".*']]>$(Configuration)\|$(Platform)<![CDATA['">((?:.*\n)*?.*)</ItemDefinitionGroup>]]></_ItemDefinitionGroupRegex>
<_RuntimeLibraryRegex><![CDATA[(?:.*\n)*?.*<RuntimeLibrary>(.*)</RuntimeLibrary>(?:.*\n)*?.*]]></_RuntimeLibraryRegex>
<_HasRuntimeLibrary>$([System.Text.RegularExpressions.Regex]::IsMatch($([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText($(ProjectPath))), $(_ItemDefinitionGroupRegex)).Result('$1')), $(_RuntimeLibraryRegex)))</_HasRuntimeLibrary>
<!--
Fix incremental build (Different results when running msbuild within Visual Studio or from console).
http://connect.microsoft.com/VisualStudio/feedback/details/677499/different-results-when-running-msbuild-within-visual-studio-or-from-console
-->
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<Choose>
<When Condition="$([System.Convert]::ToBoolean($(_HasRuntimeLibrary)))">
<!-- Extract runtime library from project file. -->
<PropertyGroup Label="UserMacros">
<_RuntimeLibrary>$([System.Text.RegularExpressions.Regex]::Match($([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText($(ProjectPath))), $(_ItemDefinitionGroupRegex)).Result('$1')), $(_RuntimeLibraryRegex)).Result('$1'))</_RuntimeLibrary>
</PropertyGroup>
</When>
<Otherwise>
<!-- Set default runtime library -->
<PropertyGroup Label="UserMacros">
<_RuntimeLibrary Condition=" '$(_IsDebug)' == 'True' ">MultiThreadedDebugDLL</_RuntimeLibrary>
<_RuntimeLibrary Condition=" '$(_IsDebug)' == 'False' ">MultiThreadedDLL</_RuntimeLibrary>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup Label="UserMacros">
<IsDebug>$(_IsDebug)</IsDebug>
<ConfigType Condition=" '$(IsDebug)' == 'True' ">Debug</ConfigType>
<ConfigType Condition=" '$(IsDebug)' == 'False' ">Release</ConfigType>
<Architecture Condition=" '$(Platform)' == 'Win32' ">x86</Architecture>
<Architecture Condition=" '$(Platform)' == 'x64' ">x64</Architecture>
<Toolset Condition=" '$(PlatformToolset)' == 'v110' ">msvc.110</Toolset>
<RuntimeLibrary>$(_RuntimeLibrary)</RuntimeLibrary>
</PropertyGroup>
<ItemGroup>
<BuildMacro Include="IsDebug">
<Value>$(IsDebug)</Value>
</BuildMacro>
<BuildMacro Include="Toolset">
<Value>$(Toolset)</Value>
</BuildMacro>
<BuildMacro Include="Architecture">
<Value>$(Architecture)</Value>
</BuildMacro>
<BuildMacro Include="RuntimeLibrary">
<Value>$(RuntimeLibrary)</Value>
</BuildMacro>
<BuildMacro Include="ConfigType">
<Value>$(ConfigType)</Value>
</BuildMacro>
</ItemGroup>
</Project>

Resources