Check .csproj files in solution

I would like to be able to check my files .csprojeither as they are added to the solution, or when they are built on our CI build server.

Validation will mean validation, for example:

  • that the correspondence of the path file name and the project file
  • that the assembly name and namespace are consistent with naming conventions
  • that the target platform is correct.
  • that the output paths are correct (Release and Debug)
  • that the warning level is correct, and that warnings are treated as errors.
  • that certain files are present in the project ( AssemblyInfo.csetc.).
  • that assemblies are correctly specified
  • etc.

Another useful feature is the ability to ignore specific projects or, even better, define groups of projects, each group having its own validation rules.

, , , , . , - StyleCop FxCop.

?

( ReSharper, , .)

+4
2

AFAIK . my .csproj .vbproj .

, , , Microsoft.Build.Evaluation.Project (Assembly Microsoft.Build). , . fooobar.com/questions/60080/....

(, ToolsVersion, TargetFrameworkVersion, TargetCPU,...) , , .

!

+1

. .csproj. , , .

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
    <ProjectGuid>$guid1$</ProjectGuid>
    <ProjectTypeGuids>{EE2C853D-36AF-4FDB-B1AD-8E90477E2198};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Exe</OutputType>
    <RootNamespace>$safeprojectname$</RootNamespace>
    <AssemblyName>$safeprojectname$</AssemblyName>
    <IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
        <AppDesignerFolder>Properties</AppDesignerFolder>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
    <DefineConstants>DEBUG</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>false</ConsolePause>
        <MtouchArch>i386, x86_64</MtouchArch>
    <MtouchLink>None</MtouchLink>
    <MtouchDebug>true</MtouchDebug>
        <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\iPhoneSimulator\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <MtouchLink>None</MtouchLink>
        <MtouchArch>i386, x86_64</MtouchArch>
        <ConsolePause>false</ConsolePause>
        <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\iPhone\Debug</OutputPath>
    <DefineConstants>DEBUG</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>false</ConsolePause>
        <MtouchArch>ARMv7, ARM64</MtouchArch>
        <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
    <CodesignKey>iPhone Developer</CodesignKey>
        <MtouchDebug>true</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\iPhone\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
        <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
        <MtouchArch>ARMv7, ARM64</MtouchArch>
    <ConsolePause>false</ConsolePause>
    <CodesignKey>iPhone Developer</CodesignKey>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>True</Optimize>
    <OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>False</ConsolePause>
        <MtouchArch>ARMv7, ARM64</MtouchArch>
        <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
    <BuildIpa>True</BuildIpa>
        <CodesignProvision>Automatic:AdHoc</CodesignProvision>
        <CodesignKey>iPhone Distribution</CodesignKey>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
    <DebugType>none</DebugType>
    <Optimize>True</Optimize>
    <OutputPath>bin\iPhone\AppStore</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>False</ConsolePause>
        <MtouchArch>ARMv7, ARM64</MtouchArch>
        <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
        <CodesignProvision>Automatic:AppStore</CodesignProvision>
    <CodesignKey>iPhone Distribution</CodesignKey>
</PropertyGroup>
<ItemGroup>
    <Compile Include="Main.cs" />
    <Compile Include="AppDelegate.cs" />
    <None Include="Info.plist"/>
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="RootViewController.designer.cs">
        <DependentUpon>RootViewController.cs</DependentUpon>
    </Compile>
    <Compile Include="RootViewController.cs" />
    <InterfaceDefinition Include="MainInterface.storyboard" />
</ItemGroup>
<ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core" />
    <Reference Include="Xamarin.iOS" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.AppExtension.CSharp.targets" />

-2

Source: https://habr.com/ru/post/1598831/


All Articles