首页 > 编程语言 >传统的ASP.NET Web Form程序如何使用最新的MSBuild特性

传统的ASP.NET Web Form程序如何使用最新的MSBuild特性

时间:2024-05-27 16:58:51浏览次数:13  
标签:Web ASP False Form Always csproj false true

摘要

旧的.csproj文件,在使用NuGet包的时候,会随着引用一个包,一下子添加n多个包。我们把旧的.csproj文件迁移到最新的格式,就能避免这个问题。

直接上效果

<Project ToolsVersion="12.0" DefaultTargets="Build" Sdk="Microsoft.NET.Sdk.Web" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!--这一行从旧版文件予以保留-->
	<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
	<PropertyGroup>
        <ProjectGuid>{4DE0EBFC-2E08-4DC0-9C26-D6B651AE054B}</ProjectGuid>
        <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>Yee.Passport.Web</RootNamespace>
        <AssemblyName>Yee.Passport.Web</AssemblyName>
        <TargetFramework>net481</TargetFramework>
        <LangVersion>latest</LangVersion>
        <UseIISExpress>true</UseIISExpress>
        <!--<OldToolsVersion>4.0</OldToolsVersion>-->
        <EnableDefaultContentItems>true</EnableDefaultContentItems>
        <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
		<CopyRoslynCompilerFilesToOutputDirectory>true</CopyRoslynCompilerFilesToOutputDirectory>
		<WebProjectOutputDirInsideProject>false</WebProjectOutputDirInsideProject>
		<WebProjectOutputDirInsideProjectDefault>false</WebProjectOutputDirInsideProjectDefault>
    </PropertyGroup>

    <!--只有这样,这些文件才会发布到目录中-->
    <ItemGroup>
        <Content Include="Global.asax">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*.aspx">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*/*.aspx">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*/*.ascx">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*/*/*.ascx">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*/*.master">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*/*.png">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*/*/*.png">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*/*.gif">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="*/*.js">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
    </ItemGroup>

    <ItemGroup>
        <Reference Include="Microsoft.CSharp" />
        <Reference Include="System" />
        <Reference Include="System.Data" />
        <Reference Include="System.Data.DataSetExtensions" />
        <Reference Include="System.Data.Entity" />
        <Reference Include="System.Drawing" />
        <Reference Include="System.Web" />
        <Reference Include="System.Web.Extensions" />
        <Reference Include="System.Xml" />
        <Reference Include="System.Configuration" />
        <Reference Include="System.Web.Services" />
        <Reference Include="System.EnterpriseServices" />
        <Reference Include="System.Web.DynamicData" />
        <Reference Include="System.Web.Entity" />
        <Reference Include="System.Web.ApplicationServices" />
        <Reference Include="System.Xml.Linq" />
    </ItemGroup>

    <ItemGroup>
        <Folder Include="App_Data\Dictionaries\" />
        <Folder Include="App_Themes\None\" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
        <PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.3.0" />
        <!--这两个包,是因为C#代码里用了动态语言等新特性,需要调用Roslyn编译器。web.config里需要有相应的system.codedom配置-->
        <PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="4.1.0" />
        <PackageReference Include="Microsoft.Net.Compilers" Version="4.2.0">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <!--这个包必须要有-->
        <PackageReference Include="MSBuild.Microsoft.VisualStudio.Web.targets" Version="$(MSBuild_Microsoft_VisualStudio_Web_targets_Version)" />
        <!--这个是因为引用了基于.NET Standard 2.0的包-->
        <PackageReference Include="NETStandard.Library" Version="2.0.3" />
        <PackageReference Include="Newtonsoft.Json" Version="$(Newtonsoft_Json_Version)" />
        <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
        <PackageReference Include="WebGrease" Version="1.6.0" />
    </ItemGroup>

    <ItemGroup>
        <ProjectReference Include="..\Hello.World.Core\Hello.World.Core.csproj" />
    </ItemGroup>

	<PropertyGroup>
		<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
		<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
	</PropertyGroup>

	<ProjectExtensions>
        <VisualStudio>
            <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
                <WebProjectProperties>
                    <UseIIS>True</UseIIS>
                    <AutoAssignPort>False</AutoAssignPort>
                    <DevelopmentServerPort>3595</DevelopmentServerPort>
                    <DevelopmentServerVPath>/</DevelopmentServerVPath>
                    <IISUrl>http://localhost:3596/</IISUrl>
                    <NTLMAuthentication>False</NTLMAuthentication>
                    <UseCustomServer>False</UseCustomServer>
                    <CustomServerUrl>
                    </CustomServerUrl>
                    <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
                </WebProjectProperties>
            </FlavorProperties>
        </VisualStudio>
    </ProjectExtensions>
    
    <!--这个两行都必须要有。MSBuild才能找到_CopyWebApplication这个Target-->
	<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
	<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

    <!--这是我的原创,加了这个Target,Roslyn的产物才会复制到网站输出目录的bin\roslyn文件夹-->
	<Target Name="CopyRoslynCompilerFilesToOutputDirectory2" AfterTargets="_CopyWebApplication">
		<ItemGroup>
			<RoslynFiles Include="$(CscToolPath)\*" />
		</ItemGroup>
		<MakeDir Directories="$(WebProjectOutputDir)\bin\roslyn" />
		<Copy SourceFiles="@(RoslynFiles)" DestinationFolder="$(WebProjectOutputDir)\bin\roslyn" SkipUnchangedFiles="true" Retries="$(CopyRetryCount)" RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
	</Target>

</Project>

标签:Web,ASP,False,Form,Always,csproj,false,true
From: https://www.cnblogs.com/amisoft/p/18215914/use-newest-msbuild-for-aspnet-web-form-applicat

相关文章

  • WebSocket服务搭建
    1、在NuGet包管理工具安装websocket包 2、添加自定义中间件app.UseWebSockets();app.UseMiddleware<CustomWebSocketMiddleware>();3、编写websocket中间件privatereadonlyRequestDelegate_next;privateILogger<CustomWebSocketMiddleware>_Logger;publicList<Web......
  • websocket实现消息实时通信
    后端代码实现1、导入依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><version>3.2.5</version></dependency>2、创建websocket客户端对象。@Getter@Set......
  • 基于Selenium+webdriver对Web应用系统进行功能测试
    以Java格式的脚本,在JUnit框架上执行和调试这些脚本。项目语言与架构选项为在pom.xml中添加的依赖在kotlin目录中添加Java类,开始编写测试代码:找到chrome的版本并下载对应版本的chromedriver,在setProperty中将chromedriver.exe的路径完善后就可以开始测试。chromedriver全版......
  • ASP+ACCESS教学评估系统
    摘 要:本文从计算机系的实际情况出发,经过对计算机系本科评估事项的一番考察和分析,确立了计算机系本科评估网站具体实现功能。并阐述网站的结构设计和功能设计,实现用户的分类显示、最近新闻的提示、留言板功能等。管理员用户可以通过Web浏览器,以人机交互式的客户端程序实现对本......
  • 【CTF Web】CTFShow web9 Writeup(RCE+PHP+代码审计)
    web91阿呆在埃塞俄比亚终于找了一个网管的工作,闲暇时还能种点菜。解法可知flag在config.php。<?php#flaginconfig.phpinclude("config.php");if(isset($_GET['c'])){$c=$_GET['c'];if(preg_match("/system|exec|highlight/i",$c......
  • 【CTF Web】CTFShow web10 Writeup(RCE+PHP+代码审计)
    web101阿呆看见对面二黑急冲冲的跑过来,告诉阿呆出大事了,阿呆问什么事,二黑说:这几天天旱,你菜死了!解法可知flag在config.php。<?php#flaginconfig.phpinclude("config.php");if(isset($_GET['c'])){$c=$_GET['c'];if(!preg_match("/system|......
  • Web Service和Web API理解和使用场景
    WebService理解:WebService是一种基于网络的服务,它使用标准化的消息传递协议,最典型的是基于SOAP(SimpleObjectAccessProtocol)协议。SOAP使用XML格式封装数据,定义了消息的结构和传输方式,因此它是一个重量级的解决方案。WebService支持跨平台、跨语言的通信,常用于企业内......
  • android studio 实现web网站变成app小程序
    MainActivity.javapackagecom.example.myapplication;importandroid.os.Bundle;importandroid.webkit.WebView;importandroid.webkit.WebViewClient;importandroidx.appcompat.app.AppCompatActivity;publicclassMainActivityextendsAppCompatActivity{......
  • Web-请求数据+号丢失问题
    1.背景先来复习下URL请求的基本知识HTTP的早期设计主要考虑了基本的文档检索需求以及表单提交功能,这直接影响了后来对POST请求和内容类型的发展。1.1请求方法HTTP(超文本传输协议)最初设计的目的是为了支持万维网上的文档检索,这涉及到请求HTML页面、图像、视频等静态资源。......
  • SUPRA:无须额外训练,将Transformer变为高效RNN,推理速度倍增
    Transformers已经确立了自己作为首要模型架构的地位,特别是因为它们在各种任务中的出色表现。但是Transformers的内存密集型性质和随着词元数量的指数扩展推理成本带来了重大挑战。为了解决这些问题,论文“LinearizingLargeLanguageModels”引入了一种创新的方法,称为UPtraining......